提交 12d9b3be 编写于 作者: J John Garry 提交者: Yang Yingliang

blk-mq-sched: Fix blk_mq_sched_alloc_tags() error handling

mainline inclusion
from mainline-v5.14-rc1
commit b93af305
category: bugfix
bugzilla: 177012
CVE: NA

---------------------------

If the blk_mq_sched_alloc_tags() -> blk_mq_alloc_rqs() call fails, then we
call blk_mq_sched_free_tags() -> blk_mq_free_rqs().

It is incorrect to do so, as any rqs would have already been freed in the
blk_mq_alloc_rqs() call.

Fix by calling blk_mq_free_rq_map() only directly.

Fixes: 6917ff0b ("blk-mq-sched: refactor scheduler initialization")
Signed-off-by: NJohn Garry <john.garry@huawei.com>
Reviewed-by: NMing Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/1627378373-148090-1-git-send-email-john.garry@huawei.comSigned-off-by: NJens Axboe <axboe@kernel.dk>

conflicts:
        block/blk-mq-sched.c
Signed-off-by: NLaibin Qiu <qiulaibin@huawei.com>
Reviewed-by: NJason Yan <yanaijie@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 23840187
...@@ -513,8 +513,10 @@ static int blk_mq_sched_alloc_tags(struct request_queue *q, ...@@ -513,8 +513,10 @@ static int blk_mq_sched_alloc_tags(struct request_queue *q,
return -ENOMEM; return -ENOMEM;
ret = blk_mq_alloc_rqs(set, hctx->sched_tags, hctx_idx, q->nr_requests); ret = blk_mq_alloc_rqs(set, hctx->sched_tags, hctx_idx, q->nr_requests);
if (ret) if (ret) {
blk_mq_sched_free_tags(set, hctx, hctx_idx); blk_mq_free_rq_map(hctx->sched_tags);
hctx->sched_tags = NULL;
}
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册