* [PATCH] block: fix resource leak in blk_register_queue() error path
@ 2025-04-12 9:25 Zheng Qixing
2025-04-14 2:58 ` Yu Kuai
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Zheng Qixing @ 2025-04-12 9:25 UTC (permalink / raw)
To: axboe; +Cc: linux-block, linux-kernel, yukuai3, yi.zhang, yangerkun,
zhengqixing
From: Zheng Qixing <zhengqixing@huawei.com>
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>
---
block/blk-sysfs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index a2882751f0d2..1f9b45b0b9ee 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -909,6 +909,8 @@ int blk_register_queue(struct gendisk *disk)
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);
return ret;
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] block: fix resource leak in blk_register_queue() error path
2025-04-12 9:25 [PATCH] block: fix resource leak in blk_register_queue() error path Zheng Qixing
@ 2025-04-14 2:58 ` Yu Kuai
2025-04-14 6:28 ` Christoph Hellwig
2025-04-14 14:48 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Yu Kuai @ 2025-04-14 2:58 UTC (permalink / raw)
To: Zheng Qixing, axboe
Cc: linux-block, linux-kernel, yi.zhang, yangerkun, zhengqixing,
yukuai (C)
在 2025/04/12 17:25, Zheng Qixing 写道:
> From: Zheng Qixing <zhengqixing@huawei.com>
>
> 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>
> ---
> block/blk-sysfs.c | 2 ++
> 1 file changed, 2 insertions(+)
>
LGTM
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index a2882751f0d2..1f9b45b0b9ee 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -909,6 +909,8 @@ int blk_register_queue(struct gendisk *disk)
> 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);
> return ret;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: fix resource leak in blk_register_queue() error path
2025-04-12 9:25 [PATCH] block: fix resource leak in blk_register_queue() error path Zheng Qixing
2025-04-14 2:58 ` Yu Kuai
@ 2025-04-14 6:28 ` Christoph Hellwig
2025-04-14 14:48 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2025-04-14 6:28 UTC (permalink / raw)
To: Zheng Qixing
Cc: axboe, linux-block, linux-kernel, yukuai3, yi.zhang, yangerkun,
zhengqixing
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: fix resource leak in blk_register_queue() error path
2025-04-12 9:25 [PATCH] block: fix resource leak in blk_register_queue() error path Zheng Qixing
2025-04-14 2:58 ` Yu Kuai
2025-04-14 6:28 ` Christoph Hellwig
@ 2025-04-14 14:48 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2025-04-14 14:48 UTC (permalink / raw)
To: Zheng Qixing
Cc: linux-block, linux-kernel, yukuai3, yi.zhang, yangerkun,
zhengqixing
On Sat, 12 Apr 2025 17:25:54 +0800, Zheng Qixing wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] block: fix resource leak in blk_register_queue() error path
commit: 40f2eb9b531475dd01b683fdaf61ca3cfd03a51e
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-14 14:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-12 9:25 [PATCH] block: fix resource leak in blk_register_queue() error path Zheng Qixing
2025-04-14 2:58 ` Yu Kuai
2025-04-14 6:28 ` Christoph Hellwig
2025-04-14 14:48 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox