提交 f16277ca 编写于 作者: S Shenghui Wang 提交者: Jens Axboe

bcache: fix wrong usage use-after-freed on keylist in out_nocoalesce branch of btree_gc_coalesce

Elements of keylist should be accessed before the list is freed.
Move bch_keylist_free() calling after the while loop to avoid wrong
content accessed.
Signed-off-by: NShenghui Wang <shhuiw@foxmail.com>
Signed-off-by: NColy Li <colyli@suse.de>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 63120731
...@@ -1476,11 +1476,11 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, ...@@ -1476,11 +1476,11 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
out_nocoalesce: out_nocoalesce:
closure_sync(&cl); closure_sync(&cl);
bch_keylist_free(&keylist);
while ((k = bch_keylist_pop(&keylist))) while ((k = bch_keylist_pop(&keylist)))
if (!bkey_cmp(k, &ZERO_KEY)) if (!bkey_cmp(k, &ZERO_KEY))
atomic_dec(&b->c->prio_blocked); atomic_dec(&b->c->prio_blocked);
bch_keylist_free(&keylist);
for (i = 0; i < nodes; i++) for (i = 0; i < nodes; i++)
if (!IS_ERR_OR_NULL(new_nodes[i])) { if (!IS_ERR_OR_NULL(new_nodes[i])) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册