six locks: Fix an unitialized var
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 25 May 2023 22:10:04 +0000 (18:10 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:02 +0000 (17:10 -0400)
In the conversion to atomic_t, six_lock_slowpath() ended up calling
six_lock_wakeup() in the failure path with a state variable that was
never initialized - whoops.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/six.c

index fa508ab2108cccf6f6124961c224a77fe921c3a2..9a5fcd7d35661b74f44554595e3d17774deb4eb6 100644 (file)
@@ -451,7 +451,6 @@ static int six_lock_slowpath(struct six_lock *lock, enum six_lock_type type,
                             six_lock_should_sleep_fn should_sleep_fn, void *p,
                             unsigned long ip)
 {
-       u32 old;
        int ret = 0;
 
        if (type == SIX_LOCK_write) {
@@ -527,7 +526,7 @@ static int six_lock_slowpath(struct six_lock *lock, enum six_lock_type type,
 out:
        if (ret && type == SIX_LOCK_write) {
                six_clear_bitmask(lock, SIX_LOCK_HELD_write);
-               six_lock_wakeup(lock, old, SIX_LOCK_read);
+               six_lock_wakeup(lock, atomic_read(&lock->state), SIX_LOCK_read);
        }
 
        return ret;