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 <kent.overstr...@linux.dev>
Date:   Wed Jul 16 17:02:31 2025 -0400

    fixup! bcachefs: convert clock.c to CLASS/guards
    
    Reported-by: Dan Carpenter <dan.carpen...@linaro.org>
    Signed-off-by: Kent Overstreet <kent.overstr...@linux.dev>

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)

Reply via email to