Re: [bug report] bcachefs: convert clock.c to CLASS/guards

Kent Overstreet <[email protected]>
Newsgroups org.kernel.vger.linux-bcachefs
Message-ID <7qr2cduhq5hqns5m4j2qmhpqcv7mahtxwsh7cofztwtbytxzet@d5hwxckffzz4>
On Wed, Jul 16, 2025 at 02:39:01PM -0500, Dan Carpenter wrote:
> Hello Kent Overstreet,
> 
> Commit 7ede8fc514bb ("bcachefs: convert clock.c to CLASS/guards")
> from Jul 14, 2025 (linux-next), leads to the following Smatch static
> checker warning:

Thanks! Applying the following:

commit db91c9d5ab0845566fa7c3de57f9992e894ab43c
Author: Kent Overstreet <[email protected]>
Date:   Wed Jul 16 17:02:31 2025 -0400

    fixup! bcachefs: convert clock.c to CLASS/guards
    
    Reported-by: Dan Carpenter <[email protected]>
    Signed-off-by: Kent Overstreet <[email protected]>

diff --git a/fs/bcachefs/clock.c b/fs/bcachefs/clock.c
index 5185794f8754..1c6d0cdca3c5 100644
--- a/fs/bcachefs/clock.c
+++ b/fs/bcachefs/clock.c
@@ -21,7 +21,7 @@ static const struct min_heap_callbacks callbacks = {
 
 void bch2_io_timer_add(struct io_clock *clock, struct io_timer *timer)
 {
-	guard(spinlock)(&clock->timer_lock);
+	spin_lock(&clock->timer_lock);
 
 	if (time_after_eq64((u64) atomic64_read(&clock->now), timer->expire)) {
 		spin_unlock(&clock->timer_lock);
@@ -31,9 +31,11 @@ void bch2_io_timer_add(struct io_clock *clock, struct io_timer *timer)
 
 	for (size_t i = 0; i < clock->timers.nr; i++)
 		if (clock->timers.data[i] == timer)
-			return;
+			goto out;
 
 	BUG_ON(!min_heap_push(&clock->timers, &timer, &callbacks, NULL));
+out:
+	spin_unlock(&clock->timer_lock);
 }
 
 void bch2_io_timer_del(struct io_clock *clock, struct io_timer *timer)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.