Skip to content

Commit

Permalink
blk-mq: fix use of incorrect goto label in blk_mq_init_queue error path
Browse files Browse the repository at this point in the history
If percpu_ref_init() fails the allocated q and hctxs must get cleaned
up; using 'err_map' doesn't allow that to happen.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Reviewed-by: Ming Lei <ming.lei@canonical.com>
Cc: stable@kernel.org
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Mike Snitzer authored and Jens Axboe committed Mar 13, 2015
1 parent b8be79b commit 9a30b09
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
*/
if (percpu_ref_init(&q->mq_usage_counter, blk_mq_usage_counter_release,
PERCPU_REF_INIT_ATOMIC, GFP_KERNEL))
goto err_map;
goto err_mq_usage;

setup_timer(&q->timeout, blk_mq_rq_timer, (unsigned long) q);
blk_queue_rq_timeout(q, 30000);
Expand Down Expand Up @@ -1981,7 +1981,7 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
blk_mq_init_cpu_queues(q, set->nr_hw_queues);

if (blk_mq_init_hw_queues(q, set))
goto err_hw;
goto err_mq_usage;

mutex_lock(&all_q_mutex);
list_add_tail(&q->all_q_node, &all_q_list);
Expand All @@ -1993,7 +1993,7 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)

return q;

err_hw:
err_mq_usage:
blk_cleanup_queue(q);
err_hctxs:
kfree(map);
Expand Down

0 comments on commit 9a30b09

Please sign in to comment.