diff options
author | Zheng Qixing <zhengqixing@huawei.com> | 2025-04-12 17:25:54 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-04-25 10:47:43 +0200 |
commit | 41e43134ddda35949974be40520460a12dda3502 (patch) | |
tree | f778d68ebd5667f54541e57733d19bcd26388772 | |
parent | 3f899bd6dd56ddc46509b526e23a8f0a97712a6d (diff) |
block: fix resource leak in blk_register_queue() error path
[ Upstream commit 40f2eb9b531475dd01b683fdaf61ca3cfd03a51e ]
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: 320ae51feed5 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | block/blk-sysfs.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 692b27266220..0e2520d929e1 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -813,6 +813,8 @@ out_unregister_ia_ranges: out_debugfs_remove: blk_debugfs_remove(disk); mutex_unlock(&q->sysfs_lock); + if (queue_is_mq(q)) + blk_mq_sysfs_unregister(disk); out_put_queue_kobj: kobject_put(&disk->queue_kobj); mutex_unlock(&q->sysfs_dir_lock); |