blob: 642cf2760b4ae00c519e52348afbafe081e01c92 [file] [log] [blame]
From: Kuan-Wei Chiu <visitorckw@gmail.com>
Subject: bcachefs: fix missing assignment of minimum element before min_heap_pop()
Date: Mon, 3 Jun 2024 01:48:28 +0800
When replacing the heap_pop() macro with min_heap_pop(), the original
heap_pop() macro would store the minimum element into 'ret'. However,
after replacing it with min_heap_pop(), the code incorrectly failed to
store the minimum element into 'ret' before deleting it.
Fix the issue by using min_heap_peek() to assign the minimum element to
'ret' before calling min_heap_pop() to remove the minimum element.
Link: https://lkml.kernel.org/r/20240602174828.1955320-1-visitorckw@gmail.com
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202406030001.jwsq6DZp-lkp@intel.com/
Cc: Ian Rogers <irogers@google.com>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
fs/bcachefs/clock.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/fs/bcachefs/clock.c~bcachefs-remove-heap-related-macros-and-switch-to-generic-min_heap-fix
+++ a/fs/bcachefs/clock.c
@@ -156,8 +156,10 @@ static struct io_timer *get_expired_time
spin_lock(&clock->timer_lock);
if (clock->timers.nr &&
- time_after_eq(now, clock->timers.data[0]->expire))
+ time_after_eq(now, clock->timers.data[0]->expire)) {
+ ret = *min_heap_peek(&clock->timers);
min_heap_pop(&clock->timers, &callbacks, NULL);
+ }
spin_unlock(&clock->timer_lock);
_