Skip to content

Commit a25a83d

Browse files
name2965Kent Overstreet
authored andcommitted
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: 7773df1 ("bcachefs: metadata version bucket_stripe_sectors") Signed-off-by: Jeongjun Park <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent 5c41f75 commit a25a83d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/bcachefs/sb-downgrade.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ UPGRADE_TABLE()
143143

144144
static int have_stripes(struct bch_fs *c)
145145
{
146+
if (IS_ERR_OR_NULL(c->btree_roots_known[BTREE_ID_stripes].b))
147+
return 0;
148+
146149
return !btree_node_fake(c->btree_roots_known[BTREE_ID_stripes].b);
147150
}
148151

0 commit comments

Comments
 (0)