From: Robert Garcia <rob_garcia@163.com>
To: stable@vger.kernel.org, Zheng Qixing <zhengqixing@huawei.com>
Cc: Jens Axboe <axboe@kernel.dk>, Robert Garcia <rob_garcia@163.com>,
Christoph Hellwig <hch@lst.de>, Yu Kuai <yukuai3@huawei.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5.15.y] block: fix resource leak in blk_register_queue() error path
Date: Thu, 9 Apr 2026 14:36:16 +0800 [thread overview]
Message-ID: <20260409063616.117503-1-rob_garcia@163.com> (raw)
From: Zheng Qixing <zhengqixing@huawei.com>
[ 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>
[ Change disk to q in blk_mq_sysfs_unregister(). ]
Signed-off-by: Robert Garcia <rob_garcia@163.com>
---
block/blk-sysfs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 4ea84e46a665..c1917992e619 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -900,6 +900,8 @@ int blk_register_queue(struct gendisk *disk)
if (q->elevator)
kobject_uevent(&q->elevator->kobj, KOBJ_ADD);
mutex_unlock(&q->sysfs_lock);
+ if (queue_is_mq(q))
+ blk_mq_sysfs_unregister(q);
ret = 0;
unlock:
--
2.34.1
reply other threads:[~2026-04-09 6:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260409063616.117503-1-rob_garcia@163.com \
--to=rob_garcia@163.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=yukuai3@huawei.com \
--cc=zhengqixing@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox