diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-08-06 21:22:24 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:08:43 +0200 |
commit | 2d8c0da1a7c2601b21d3fb63b8cb4f3610cac196 (patch) | |
tree | af1f5851a48dea35124b73f51ace8501fb026026 /fs/bcachefs/disk_groups.c | |
parent | bcachefs: Fix disk groups not being updated when set via sysfs (diff) | |
download | linux-2d8c0da1a7c2601b21d3fb63b8cb4f3610cac196.tar.xz linux-2d8c0da1a7c2601b21d3fb63b8cb4f3610cac196.zip |
bcachefs: Fix a couple null ptr derefs when no disk groups exist
Normally successfully parsing a target means disk groups should exist,
but we don't want a BUG() or null ptr deref if we end up with an invalid
target.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/disk_groups.c')
-rw-r--r-- | fs/bcachefs/disk_groups.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/bcachefs/disk_groups.c b/fs/bcachefs/disk_groups.c index 1c30065833c2..c47fa0a0f450 100644 --- a/fs/bcachefs/disk_groups.c +++ b/fs/bcachefs/disk_groups.c @@ -183,7 +183,7 @@ const struct bch_devs_mask *bch2_target_to_mask(struct bch_fs *c, unsigned targe case TARGET_GROUP: { struct bch_disk_groups_cpu *g = rcu_dereference(c->disk_groups); - return t.group < g->nr && !g->entries[t.group].deleted + return g && t.group < g->nr && !g->entries[t.group].deleted ? &g->entries[t.group].devs : NULL; } @@ -208,7 +208,7 @@ bool bch2_dev_in_target(struct bch_fs *c, unsigned dev, unsigned target) rcu_read_lock(); g = rcu_dereference(c->disk_groups); - m = t.group < g->nr && !g->entries[t.group].deleted + m = g && t.group < g->nr && !g->entries[t.group].deleted ? &g->entries[t.group].devs : NULL; |