bcachefs: Fix a null ptr deref

bch2_btree_iter_peek() won't always return a key - whoops.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2021-05-23 18:42:51 -04:00 committed by Kent Overstreet
parent 9dd89a05fd
commit 443d2760e5

View File

@ -522,6 +522,11 @@ static int lookup_inode(struct btree_trans *trans, struct bpos pos,
if (ret)
goto err;
if (!k.k || bkey_cmp(k.k->p, pos)) {
ret = -ENOENT;
goto err;
}
ret = k.k->type == KEY_TYPE_inode ? 0 : -EIO;
if (ret)
goto err;