Commit a25a83de authored by Jeongjun Park's avatar Jeongjun Park Committed by Kent Overstreet
Browse files

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: default avatar <syzbot+b468b9fef56949c3b528@syzkaller.appspotmail.com>
Fixes: 7773df19 ("bcachefs: metadata version bucket_stripe_sectors")
Signed-off-by: default avatarJeongjun Park <aha310510@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 5c41f75d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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);
}