Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: null_blk: fix queue leak inside removing device

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>

authored by

Ming Lei and committed by
Linus Torvalds
518d00b7 228fdc08

+2 -8
+2 -8
drivers/block/null_blk.c
··· 425 425 list_del_init(&nullb->list); 426 426 427 427 del_gendisk(nullb->disk); 428 - if (queue_mode == NULL_Q_MQ) 429 - blk_mq_free_queue(nullb->q); 430 - else 431 - blk_cleanup_queue(nullb->q); 428 + blk_cleanup_queue(nullb->q); 432 429 put_disk(nullb->disk); 433 430 kfree(nullb); 434 431 } ··· 575 578 disk = nullb->disk = alloc_disk_node(1, home_node); 576 579 if (!disk) { 577 580 queue_fail: 578 - if (queue_mode == NULL_Q_MQ) 579 - blk_mq_free_queue(nullb->q); 580 - else 581 - blk_cleanup_queue(nullb->q); 581 + blk_cleanup_queue(nullb->q); 582 582 cleanup_queues(nullb); 583 583 err: 584 584 kfree(nullb);