mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] bcachefs: Fix missing assignment of minimum element before min_heap_pop()
       [not found] <202406030001.jwsq6DZp-lkp@intel.com>
@ 2024-06-02 17:48 ` Kuan-Wei Chiu
  0 siblings, 0 replies; only message in thread
From: Kuan-Wei Chiu @ 2024-06-02 17:48 UTC (permalink / raw)
  To: akpm
  Cc: kent.overstreet, bfoster, irogers, linux-bcachefs, linux-kernel,
	oe-kbuild-all, lkp, Kuan-Wei Chiu

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@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202406030001.jwsq6DZp-lkp@intel.com/
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-06-02 17:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <202406030001.jwsq6DZp-lkp@intel.com>
2024-06-02 17:48 ` [PATCH] bcachefs: Fix missing assignment of minimum element before min_heap_pop() Kuan-Wei Chiu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®