]> git.baikalelectronics.ru Git - kernel.git/commit
ublk_drv: fix request queue leak
authorMing Lei <ming.lei@redhat.com>
Thu, 14 Jul 2022 10:32:01 +0000 (18:32 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 14 Jul 2022 13:16:04 +0000 (07:16 -0600)
commite40cb4715158e36d8efa39bc3fe7e5684f559e03
tree7ce64abd80d8b9f19a9ea8ef0d6af7955ddcf7c2
parentd9fa9c863d784eb2769b5a239363e742df5cc84e
ublk_drv: fix request queue leak

Call blk_cleanup_queue() in release code path for fixing request
queue leak.

Also for-5.20/block has cleaned up blk_cleanup_queue(), which is
basically merged to del_gendisk() if blk_mq_alloc_disk() is used
for allocating disk and queue.

However, ublk may not add disk in case of starting device failure, then
del_gendisk() won't be called when removing ublk device, so blk_mq_exit_queue
will not be callsed, and it can be bit hard to deal with this kind of
merge conflict.

Turns out ublk's queue/disk use model is very similar with scsi, so switch
to scsi's model by allocating disk and queue independently, then it can be
quite easy to handle v5.20 merge conflict by replacing blk_cleanup_queue
with blk_mq_destroy_queue.

Reported-by: Jens Axboe <axboe@kernel.dk>
Fixes: 44155c24ce3c ("ublk_drv: add io_uring based userspace block driver")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20220714103201.131648-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c