summaryrefslogtreecommitdiff
path: root/fs/bcachefs/super.c
diff options
context:
space:
mode:
authorDan Robertson <dan@dlrobertson.com>2021-05-12 14:07:57 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:03 -0400
commitec4ab9d2fc08132113dc5d45ac68af2158377122 (patch)
treeef2e47944861262ebd83b07ada714d35f6903e17 /fs/bcachefs/super.c
parentbaf056b87da88b0c9812d53f8b12072652d1c07b (diff)
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: Dan Robertson <dan@dlrobertson.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/super.c')
-rw-r--r--fs/bcachefs/super.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 9065e264c567..71493b5ff695 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -117,7 +117,7 @@ struct bch_fs *bch2_dev_to_fs(dev_t dev)
list_for_each_entry(c, &bch_fs_list, list)
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);
goto found;
}