]> git.baikalelectronics.ru Git - kernel.git/commit
md: fix mddev->kobj lifetime
authorChristoph Hellwig <hch@lst.de>
Tue, 19 Jul 2022 09:18:15 +0000 (11:18 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 2 Aug 2022 23:22:43 +0000 (17:22 -0600)
commitf269e50e4cd386036e498c61c27a710fb4733d37
tree9ae0fbade1d262b2ecb5639f14a97bf580815dbe
parentf45af5951a3729f787d23fd394afb5019b376b5c
md: fix mddev->kobj lifetime

Once a kobject is initialized, the containing object should not be
directly freed.  So delay initialization until it is added.  Also
remove the kobject_del call as the last put will remove the kobject as
well.  The explicitly delete isn't needed here, and dropping it will
simplify further fixes.

With this md_free now does not need to check that ->gendisk is non-NULL
as it is always set by the time that kobject_init is called on
mddev->kobj.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/md.c