aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorNeil Brown <neilb@notabene.brown>2008-06-27 18:31:17 -0400
committerNeil Brown <neilb@notabene.brown>2008-06-27 18:31:17 -0400
commit9bbbca3a0ee09293108b67835c6bdf6196d7bcb3 (patch)
tree32526078700e26c6e67aea5eb141fe152d1da9f7 /drivers/md
parentefe311431869b40d67911820a309f9a1a41306f3 (diff)
Fix error paths if md_probe fails.
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: <stable@kernel.org> Cc: Dave Jones <davej@redhat.com> Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/md.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7cf512a34ccf..2580ac1b9b0f 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3897,8 +3897,10 @@ static void autorun_devices(int part)
3897 3897
3898 md_probe(dev, NULL, NULL); 3898 md_probe(dev, NULL, NULL);
3899 mddev = mddev_find(dev); 3899 mddev = mddev_find(dev);
3900 if (!mddev) { 3900 if (!mddev || !mddev->gendisk) {
3901 printk(KERN_ERR 3901 if (mddev)
3902 mddev_put(mddev);
3903 printk(KERN_ERR
3902 "md: cannot allocate memory for md drive.\n"); 3904 "md: cannot allocate memory for md drive.\n");
3903 break; 3905 break;
3904 } 3906 }