Skip to contentSkip to conversation

block: fix kobject leak in blk_unregister_queue

PATCH Applied Ming Lei 2 participants 2 messages Jul 11, 2025 – Jul 12, 2025 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 block: fix kobject leak in blk_unregister_queue

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 <[email protected]>
---
 block/blk-sysfs.c | 1 +
 1 file changed, 1 insertion(+)
block/blk-sysfs.c +1 -0
index b2b9b89d6967..c611444480b3 100644
@@ -960,4 +960,5 @@ void blk_unregister_queue(struct gendisk *disk)
 		elevator_set_none(q);
 
 	blk_debugfs_remove(disk);
+	kobject_put(&disk->queue_kobj);
 }
Signature · 1 line
2.47.0
maintainer Applied
#1 lore raw
Quoted 9 lines · Ming Lei

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,

Signature · 1 line
Jens Axboe