Skip to content

Commit 40f2eb9

Browse files
Zheng Qixingaxboe
authored andcommitted
block: fix resource leak in blk_register_queue() error path
When registering a queue fails after blk_mq_sysfs_register() is successful but the function later encounters an error, we need to clean up the blk_mq_sysfs resources. Add the missing blk_mq_sysfs_unregister() call in the error path to properly clean up these resources and prevent a memory leak. Fixes: 320ae51 ("blk-mq: new multi-queue block IO queueing mechanism") Signed-off-by: Zheng Qixing <zhengqixing@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Yu Kuai <yukuai3@huawei.com> Link: https://lore.kernel.org/r/20250412092554.475218-1-zhengqixing@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 1b41940 commit 40f2eb9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

block/blk-sysfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,8 @@ int blk_register_queue(struct gendisk *disk)
909909
out_debugfs_remove:
910910
blk_debugfs_remove(disk);
911911
mutex_unlock(&q->sysfs_lock);
912+
if (queue_is_mq(q))
913+
blk_mq_sysfs_unregister(disk);
912914
out_put_queue_kobj:
913915
kobject_put(&disk->queue_kobj);
914916
return ret;

0 commit comments

Comments
 (0)