diff options
author | Neil Brown <neilb@notabene.brown> | 2008-07-03 02:45:30 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-07-24 09:14:02 -0700 |
commit | 583fe2db21978453aa522f56320f15b2de0d9d88 (patch) | |
tree | 76165b8c1a20a68d1c14e2ff174244a3a986c56b | |
parent | 3cf5f2ed4231e64036fc8b80612e26efac0f53d4 (diff) |
md: Fix error paths if md_probe fails.
commit 9bbbca3a0ee09293108b67835c6bdf6196d7bcb3 upstream
md_probe can fail (e.g. alloc_disk could fail) without
returning an error (as it alway returns NULL).
So when we call mddev_find immediately afterwards, we need
to check that md_probe actually succeeded. This means checking
that mdev->gendisk is non-NULL.
Cc: Dave Jones <davej@redhat.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/md/md.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index ba34990a6b50..94e5711c7cc4 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -3804,8 +3804,10 @@ static void autorun_devices(int part) md_probe(dev, NULL, NULL); mddev = mddev_find(dev); - if (!mddev) { - printk(KERN_ERR + if (!mddev || !mddev->gendisk) { + if (mddev) + mddev_put(mddev); + printk(KERN_ERR "md: cannot allocate memory for md drive.\n"); break; } |