From: "zhengbin (A)" <zhengbin13@huawei.com>
To: <axboe@kernel.dk>, <ming.lei@redhat.com>, <linux-block@vger.kernel.org>
Cc: <yi.zhang@huawei.com>, <bvanassche@acm.org>
Subject: Re: [PATCH] blk-mq: Fix memory leak in blk_mq_init_allocated_queue error handling
Date: Mon, 12 Aug 2019 16:53:02 +0800 [thread overview]
Message-ID: <52cb9a64-b67f-114e-ddc2-338d8d201f40@huawei.com> (raw)
In-Reply-To: <1563891042-25448-1-git-send-email-zhengbin13@huawei.com>
ping
On 2019/7/23 22:10, zhengbin wrote:
> If blk_mq_init_allocated_queue->elevator_init_mq fails, need to release
> the previously requested resources.
>
> Fixes: d34849913 ("blk-mq-sched: allow setting of default IO scheduler")
> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> ---
> block/blk-mq.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index b038ec6..e001610 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2845,6 +2845,8 @@ static unsigned int nr_hw_queues(struct blk_mq_tag_set *set)
> struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
> struct request_queue *q)
> {
> + int ret = -ENOMEM;
> +
> /* mark the queue as mq asap */
> q->mq_ops = set->ops;
>
> @@ -2906,17 +2908,18 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
> blk_mq_map_swqueue(q);
>
> if (!(set->flags & BLK_MQ_F_NO_SCHED)) {
> - int ret;
> -
> ret = elevator_init_mq(q);
> if (ret)
> - return ERR_PTR(ret);
> + goto err_tag_set;
> }
>
> return q;
>
> +err_tag_set:
> + blk_mq_del_queue_tag_set(q);
> err_hctxs:
> kfree(q->queue_hw_ctx);
> + q->nr_hw_queues = 0;
> err_sys_init:
> blk_mq_sysfs_deinit(q);
> err_poll:
> --
> 2.7.4
>
>
> .
>
next prev parent reply other threads:[~2019-08-12 8:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 14:10 [PATCH] blk-mq: Fix memory leak in blk_mq_init_allocated_queue error handling zhengbin
2019-08-12 8:53 ` zhengbin (A) [this message]
2019-08-12 14:17 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52cb9a64-b67f-114e-ddc2-338d8d201f40@huawei.com \
--to=zhengbin13@huawei.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=yi.zhang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).