md: fix mddev->kobj lifetime
mainline inclusion from mainline-v6.0-rc1 commit ca39f750 category: bugfix bugzilla: 188733, https://gitee.com/openeuler/kernel/issues/I81XCK, https://gitee.com/openeuler/kernel/issues/I81XCK Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ca39f7502425d437cbf83d29d99b43bd61342858 ------------------------------------------------- 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> Conflict: drivers/md/md.c Commit 8b9ab626 ("block: remove blk_cleanup_disk") change blk_cleanup_disk() to put_disk(). Keep using blk_cleanup_disk() here. Signed-off-by:
Li Nan <linan122@huawei.com>
Loading
Please sign in to comment