bcachefs: fix null-ptr-deref in have_stripes()
PATCH 1/1 bcachefs: fix null-ptr-deref in have_stripes()
c->btree_roots_known[i].b can be NULL. In this case, a NULL pointer dereference occurs, so you need to add code to check the variable.
Reported-by [email protected]
Fixes ("bcachefs: metadata version bucket_stripe_sectors")
Signed-off-by Jeongjun Park <[email protected]>
--- fs/bcachefs/sb-downgrade.c | 3 +++ 1 file changed, 3 insertions(+)
fs/bcachefs/sb-downgrade.c +3 -0
@@ -143,6 +143,9 @@ UPGRADE_TABLE()static int have_stripes (struct bch_fs *c) { +if (IS_ERR_OR_NULL (c->btree_roots_known[BTREE_ID_stripes].b)) +return 0 ; +return !btree_node_fake (c->btree_roots_known[BTREE_ID_stripes].b); }
--
Kent Overstreet
AppliedQuoted 6 lines · Jeongjun Park
c->btree_roots_known[i].b can be NULL. In this case, a NULL pointer dereference occurs, so you need to add code to check the variable.
Reported-by [email protected]Fixes ("bcachefs: metadata version bucket_stripe_sectors")Signed-off-by Jeongjun Park <[email protected]>
Thanks, applied