Commit 6f5869ff authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Fix use after free in bch2_check_fix_ptrs()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 812a9297
......@@ -691,12 +691,6 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id
}
}
ret = bch2_journal_key_insert_take(c, btree_id, level, new);
if (ret) {
kfree(new);
goto err;
}
if (level)
bch2_btree_node_update_key_early(trans, btree_id, level - 1, *k, new);
......@@ -710,6 +704,12 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id
bch_info(c, "new key %s", buf.buf);
}
ret = bch2_journal_key_insert_take(c, btree_id, level, new);
if (ret) {
kfree(new);
goto err;
}
*k = bkey_i_to_s_c(new);
}
err:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment