Skip to content

Commit

Permalink
md: check the return of mddev_find()
Browse files Browse the repository at this point in the history
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 <yuanhan.liu@linux.intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information
Yuanhan Liu authored and NeilBrown committed May 22, 2012
1 parent 4f0a5e0 commit 0c09822
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0c09822

Please sign in to comment.