]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
block: fix resource leak in blk_register_queue() error path
authorZheng Qixing <zhengqixing@huawei.com>
Sat, 12 Apr 2025 09:25:54 +0000 (17:25 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:45:42 +0000 (10:45 +0200)
commit549cbbd14bbec12469ceb279b79c763c8a24224e
tree60ca66683752c7744f97218b19742d5d136b7944
parenta8a3b61ce140e2b0a72a779e8d70f60c0cf1e47a
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>
block/blk-sysfs.c