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

md: fix error handling in md_alloc

mainline inclusion
from mainline-v6.0-rc1
commit c57094a6
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I81XCK

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c57094a6e1ed5dd2d6401f79b8e6da34dd28f959



--------------------------------

Error handling in md_alloc is a mess.  Untangle it to just free the mddev
directly before add_disk is called and thus the gendisk is globally
visible.  After that clear the hold flag and let the mddev_put take care
of cleaning up the mddev through the usual mechanisms.

Fixes: 5e55e2f5 ("[PATCH] md: convert compile time warnings into runtime warnings")
Fixes: 9be68dd7 ("md: add error handling support for add_disk()")
Fixes: 7ad10691 ("md: properly unwind when failing to add the kobject in md_alloc")
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. And add_disk_safe().

Signed-off-by: default avatarLi Nan <linan122@huawei.com>
parent da72f3d2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment