From: Neil Brown Date: Fri, 27 Jun 2008 22:31:17 +0000 (+1000) Subject: Fix error paths if md_probe fails. X-Git-Tag: v2.6.26-rc9~82^2 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9bbbca3a0ee09293108b67835c6bdf6196d7bcb3;p=linux-2.6 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: Cc: Dave Jones Signed-off-by: Neil Brown --- diff --git a/drivers/md/md.c b/drivers/md/md.c index 7cf512a34c..2580ac1b9b 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -3897,8 +3897,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; }