]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
block: fix kobject leak in blk_unregister_queue
authorMing Lei <ming.lei@redhat.com>
Fri, 11 Jul 2025 08:30:09 +0000 (16:30 +0800)
committerJens Axboe <axboe@kernel.dk>
Sat, 12 Jul 2025 02:39:23 +0000 (20:39 -0600)
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>
Link: https://lore.kernel.org/r/20250711083009.2574432-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-sysfs.c

index b2b9b89d6967ca9675a1648a6f0a3a253c1c2b5d..c611444480b320bb04d0b2259ac6330b688bdcb3 100644 (file)
@@ -960,4 +960,5 @@ void blk_unregister_queue(struct gendisk *disk)
                elevator_set_none(q);
 
        blk_debugfs_remove(disk);
+       kobject_put(&disk->queue_kobj);
 }