From 0c098220e2320c1f0c9339d0ff05c5e04672133a Mon Sep 17 00:00:00 2001 From: Yuanhan Liu Date: Tue, 22 May 2012 13:55:32 +1000 Subject: md: check the return of mddev_find() Check the return of mddev_find(), since it may fail due to out of memeory or out of usable minor number. The reason I chose -ENODEV instead of -ENOMEM or something else is md_alloc() function chose that ;) Signed-off-by: Yuanhan Liu Signed-off-by: NeilBrown --- drivers/md/md.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/md/md.c') diff --git a/drivers/md/md.c b/drivers/md/md.c index 4c9836885d3e..1c2f9048e1ae 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -6618,6 +6618,9 @@ static int md_open(struct block_device *bdev, fmode_t mode) struct mddev *mddev = mddev_find(bdev->bd_dev); int err; + if (!mddev) + return -ENODEV; + if (mddev->gendisk != bdev->bd_disk) { /* we are racing with mddev_put which is discarding this * bd_disk. -- cgit v1.2.3