]> www.infradead.org Git - nvme.git/commitdiff
bcachefs: Fix bch2_dev_lookup() refcounting
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 4 May 2024 16:51:49 +0000 (12:51 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 6 May 2024 14:58:17 +0000 (10:58 -0400)
bch2_dev_lookup() is supposed to take a ref on the device it returns, but
for_each_member_device() takes refs as it iterates,
for_each_member_device_rcu() does not.

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

index 88e214c609bb2b6beab65b604acf1053596f3a8a..c2c80e6890aee3dd333caf9686ca01881084c612 100644 (file)
@@ -2004,13 +2004,9 @@ err:
 /* return with ref on ca->ref: */
 struct bch_dev *bch2_dev_lookup(struct bch_fs *c, const char *name)
 {
-       rcu_read_lock();
-       for_each_member_device_rcu(c, ca, NULL)
-               if (!strcmp(name, ca->name)) {
-                       rcu_read_unlock();
+       for_each_member_device(c, ca)
+               if (!strcmp(name, ca->name))
                        return ca;
-               }
-       rcu_read_unlock();
        return ERR_PTR(-BCH_ERR_ENOENT_dev_not_found);
 }