mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-05 09:49:58 -04:00
bcachefs: Heap code fix
When deleting an entry from a heap that was at entry h->used - 1, we'd end up calling heap_sift() on an entry outside the heap - the entry we just removed - which would end up re-adding it to the heap and deleting something we didn't want to delete. Oops... Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
committed by
Kent Overstreet
parent
fd1e9c6995
commit
30690c441a
@@ -210,9 +210,11 @@ do { \
|
||||
\
|
||||
BUG_ON(_i >= (h)->used); \
|
||||
(h)->used--; \
|
||||
heap_swap(h, _i, (h)->used, set_backpointer); \
|
||||
heap_sift_up(h, _i, cmp, set_backpointer); \
|
||||
heap_sift_down(h, _i, cmp, set_backpointer); \
|
||||
if ((_i) < (h)->used) { \
|
||||
heap_swap(h, _i, (h)->used, set_backpointer); \
|
||||
heap_sift_up(h, _i, cmp, set_backpointer); \
|
||||
heap_sift_down(h, _i, cmp, set_backpointer); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define heap_pop(h, d, cmp, set_backpointer) \
|
||||
|
||||
Reference in New Issue
Block a user