bcachefs: nocow locking: Fix lock leak
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 25 Sep 2023 01:05:50 +0000 (21:05 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:15 +0000 (17:10 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/io_write.c

index d2a0de8..6e4f85e 100644 (file)
@@ -1376,10 +1376,12 @@ err_get_ioref:
        /* Fall back to COW path: */
        goto out;
 err_bucket_stale:
-       while (--i >= 0)
+       while (i >= 0) {
                bch2_bucket_nocow_unlock(&c->nocow_locks,
                                         buckets[i].b,
                                         BUCKET_NOCOW_LOCK_UPDATE);
+               --i;
+       }
        for (i = 0; i < nr_buckets; i++)
                percpu_ref_put(&bch_dev_bkey_exists(c, buckets[i].b.inode)->io_ref);