* [PATCH] block: fix kobject leak in blk_unregister_queue
@ 2025-07-11 8:30 Ming Lei
2025-07-12 2:40 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Ming Lei @ 2025-07-11 8:30 UTC (permalink / raw)
To: Jens Axboe, linux-block; +Cc: Ming Lei, Christoph Hellwig
The kobject for the queue, `disk->queue_kobj`, is initialized with a
reference count of 1 via `kobject_init()` in `blk_register_queue()`.
While `kobject_del()` is called during the unregister path to remove
the kobject from sysfs, the initial reference is never released.
Add a call to `kobject_put()` in `blk_unregister_queue()` to properly
decrement the reference count and fix the leak.
Fixes: 2bd85221a625 ("block: untangle request_queue refcounting from sysfs")
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/blk-sysfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index b2b9b89d6967..c611444480b3 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -960,4 +960,5 @@ void blk_unregister_queue(struct gendisk *disk)
elevator_set_none(q);
blk_debugfs_remove(disk);
+ kobject_put(&disk->queue_kobj);
}
--
2.47.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] block: fix kobject leak in blk_unregister_queue
2025-07-11 8:30 [PATCH] block: fix kobject leak in blk_unregister_queue Ming Lei
@ 2025-07-12 2:40 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2025-07-12 2:40 UTC (permalink / raw)
To: linux-block, Ming Lei; +Cc: Christoph Hellwig
On Fri, 11 Jul 2025 16:30:09 +0800, Ming Lei wrote:
> The kobject for the queue, `disk->queue_kobj`, is initialized with a
> reference count of 1 via `kobject_init()` in `blk_register_queue()`.
> While `kobject_del()` is called during the unregister path to remove
> the kobject from sysfs, the initial reference is never released.
>
> Add a call to `kobject_put()` in `blk_unregister_queue()` to properly
> decrement the reference count and fix the leak.
>
> [...]
Applied, thanks!
[1/1] block: fix kobject leak in blk_unregister_queue
(no commit info)
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-12 2:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-11 8:30 [PATCH] block: fix kobject leak in blk_unregister_queue Ming Lei
2025-07-12 2:40 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox