Skip to content

Commit

Permalink
block: null_blk: fix queue leak inside removing device
Browse files Browse the repository at this point in the history
When queue_mode is NULL_Q_MQ and null_blk is being removed,
blk_cleanup_queue() isn't called to cleanup queue, so the queue
allocated won't be freed.

This patch calls blk_cleanup_queue() for MQ to drain all pending
requests first and release the reference counter of queue kobject, then
blk_mq_free_queue() will be called in queue kobject's release handler
when queue kobject's reference counter drops to zero.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
ming1 authored and torvalds committed Jan 12, 2014
1 parent 228fdc0 commit 518d00b
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions drivers/block/null_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,7 @@ static void null_del_dev(struct nullb *nullb)
list_del_init(&nullb->list);

del_gendisk(nullb->disk);
if (queue_mode == NULL_Q_MQ)
blk_mq_free_queue(nullb->q);
else
blk_cleanup_queue(nullb->q);
blk_cleanup_queue(nullb->q);
put_disk(nullb->disk);
kfree(nullb);
}
Expand Down Expand Up @@ -578,10 +575,7 @@ static int null_add_dev(void)
disk = nullb->disk = alloc_disk_node(1, home_node);
if (!disk) {
queue_fail:
if (queue_mode == NULL_Q_MQ)
blk_mq_free_queue(nullb->q);
else
blk_cleanup_queue(nullb->q);
blk_cleanup_queue(nullb->q);
cleanup_queues(nullb);
err:
kfree(nullb);
Expand Down

0 comments on commit 518d00b

Please sign in to comment.