1

bcachefs: Fix rand_delete() test

When we didn't find a key to delete we were getting a null ptr deref.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2020-12-07 11:44:12 -05:00 committed by Kent Overstreet
parent a2bfc8412a
commit d5b98fe2d7

View File

@ -563,15 +563,14 @@ static int __do_delete(struct btree_trans *trans, struct bpos pos)
iter = bch2_trans_get_iter(trans, BTREE_ID_XATTRS, pos, iter = bch2_trans_get_iter(trans, BTREE_ID_XATTRS, pos,
BTREE_ITER_INTENT); BTREE_ITER_INTENT);
ret = PTR_ERR_OR_ZERO(iter);
if (ret)
goto err;
k = bch2_btree_iter_peek(iter); k = bch2_btree_iter_peek(iter);
ret = bkey_err(k); ret = bkey_err(k);
if (ret) if (ret)
goto err; goto err;
if (!k.k)
goto err;
bkey_init(&delete.k); bkey_init(&delete.k);
delete.k.p = k.k->p; delete.k.p = k.k->p;