Skip to content

Commit 3a2d025

Browse files
author
Kent Overstreet
committed
bcachefs: Fix bch2_dev_lookup() refcounting
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>
1 parent 1267df4 commit 3a2d025

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

fs/bcachefs/super.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,13 +2004,9 @@ int bch2_dev_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets)
20042004
/* return with ref on ca->ref: */
20052005
struct bch_dev *bch2_dev_lookup(struct bch_fs *c, const char *name)
20062006
{
2007-
rcu_read_lock();
2008-
for_each_member_device_rcu(c, ca, NULL)
2009-
if (!strcmp(name, ca->name)) {
2010-
rcu_read_unlock();
2007+
for_each_member_device(c, ca)
2008+
if (!strcmp(name, ca->name))
20112009
return ca;
2012-
}
2013-
rcu_read_unlock();
20142010
return ERR_PTR(-BCH_ERR_ENOENT_dev_not_found);
20152011
}
20162012

0 commit comments

Comments
 (0)