]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 24 Jul 2025 06:53:17 +0000 (08:53 +0200)
commit21033b49cf094ebd9c545ea7b9bed04d084ce84d
tree3bfdfe7693bc5a335d70d0c10997bb25901eb83b
parentc20dd7e8f359b20fed1bd284c23df1aed8bbb9c6
block: fix kobject leak in blk_unregister_queue

[ Upstream commit 3051247e4faa32a3d90c762a243c2c62dde310db ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-sysfs.c