block: fix kobject leak in blk_unregister_queue
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.
--- block/blk-sysfs.c | 1 + 1 file changed, 1 insertion(+)
block/blk-sysfs.c +1 -0
@@ -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
Quoted 9 lines · Ming Lei
The kobject for the queue,
disk->queue_kobj, is initialized with a reference count of 1 viakobject_init()inblk_register_queue(). Whilekobject_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()inblk_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