Commit ec4ab9d2 authored by Dan Robertson's avatar Dan Robertson Committed by Kent Overstreet

bcachefs: Fix possible null deref on mount

Ensure that the block device pointer in a superblock handle is not
null before dereferencing it in bch2_dev_to_fs. The block device pointer
may be null when mounting a new bcachefs filesystem given another mounted
bcachefs filesystem exists that has at least one device that is offline.
Signed-off-by: default avatarDan Robertson <dan@dlrobertson.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent baf056b8
...@@ -117,7 +117,7 @@ struct bch_fs *bch2_dev_to_fs(dev_t dev) ...@@ -117,7 +117,7 @@ struct bch_fs *bch2_dev_to_fs(dev_t dev)
list_for_each_entry(c, &bch_fs_list, list) list_for_each_entry(c, &bch_fs_list, list)
for_each_member_device_rcu(ca, c, i, NULL) for_each_member_device_rcu(ca, c, i, NULL)
if (ca->disk_sb.bdev->bd_dev == dev) { if (ca->disk_sb.bdev && ca->disk_sb.bdev->bd_dev == dev) {
closure_get(&c->cl); closure_get(&c->cl);
goto found; goto found;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment