Message ID | 728065d3-0100-514a-70b0-66b1cfe85480@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Jun 01, 2017 at 01:02:40PM +0800, Joseph Qi wrote: > From: Joseph Qi <qijiang.qj@alibaba-inc.com> > > If error occurs, we have to free the allocated callback in > blk_mq_init_allocated_queue to avoid memory leaking. Nak. If blk_mq_init_allocated_queue() fails, we call blk_cleanup_queue() which will do this.
diff --git a/block/blk-mq.c b/block/blk-mq.c index f2224ffd..50b5d7b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2273,7 +2273,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, q->queue_ctx = alloc_percpu(struct blk_mq_ctx); if (!q->queue_ctx) - goto err_exit; + goto err_poll_cb; /* init q->mq_kobj and sw queues' kobjects */ blk_mq_sysfs_init(q); @@ -2346,6 +2346,8 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, kfree(q->queue_hw_ctx); err_percpu: free_percpu(q->queue_ctx); +err_poll_cb: + blk_stat_free_callback(q->poll_cb); err_exit: q->mq_ops = NULL; return ERR_PTR(-ENOMEM);