[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240602174828.1955320-1-visitorckw@gmail.com>
Date: Mon, 3 Jun 2024 01:48:28 +0800
From: Kuan-Wei Chiu <visitorckw@...il.com>
To: akpm@...ux-foundation.org
Cc: kent.overstreet@...ux.dev,
bfoster@...hat.com,
irogers@...gle.com,
linux-bcachefs@...r.kernel.org,
linux-kernel@...r.kernel.org,
oe-kbuild-all@...ts.linux.dev,
lkp@...el.com,
Kuan-Wei Chiu <visitorckw@...il.com>
Subject: [PATCH] bcachefs: Fix missing assignment of minimum element before min_heap_pop()
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.
Reported-by: kernel test robot <lkp@...el.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202406030001.jwsq6DZp-lkp@intel.com/
Signed-off-by: Kuan-Wei Chiu <visitorckw@...il.com>
---
fs/bcachefs/clock.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/bcachefs/clock.c b/fs/bcachefs/clock.c
index 3ec64fe6a064..18fab9c44b1b 100644
--- a/fs/bcachefs/clock.c
+++ b/fs/bcachefs/clock.c
@@ -156,8 +156,10 @@ static struct io_timer *get_expired_timer(struct io_clock *clock,
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);
--
2.34.1
Powered by blists - more mailing lists