]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
Fix error paths if md_probe fails.
authorNeil Brown <neilb@notabene.brown>
Fri, 27 Jun 2008 22:31:17 +0000 (08:31 +1000)
committerNeil Brown <neilb@notabene.brown>
Fri, 27 Jun 2008 22:31:17 +0000 (08:31 +1000)
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>
drivers/md/md.c

index 7cf512a34ccfc1ecd84c5264aff7d44184a14d95..2580ac1b9b0ff06f34d37f12ea829682017e5ef1 100644 (file)
@@ -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;
                }