Commit ece14f97 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Li Nan
Browse files

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarLogan Gunthorpe <logang@deltatee.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarSong Liu <song@kernel.org>
Signed-off-by: default avatarJens 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: default avatarLi Nan <linan122@huawei.com>
parent 14f37d25
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment