[PATCH] Fix failure paths in modules init in umem.c
authorNeilBrown <neilb@suse.de>
Thu, 1 Mar 2007 04:11:12 +0000 (20:11 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Thu, 1 Mar 2007 22:53:36 +0000 (14:53 -0800)
If register_blkdev() or alloc-disk fail in mm_init() after
pci_register_driver() succeeds, then mm_pci_driver is not unregistered
properly:

Cc: Philip Guo <pg@cs.stanford.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/block/umem.c

index dff3766f117f3307fdc52fbb46a9126db32d4a14..5872036e8ae6b90f36b2c29789c826755f0d7903 100644 (file)
@@ -1179,8 +1179,10 @@ static int __init mm_init(void)
                return -ENOMEM;
 
        err = major_nr = register_blkdev(0, "umem");
-       if (err < 0)
+       if (err < 0) {
+               pci_unregister_driver(&mm_pci_driver);
                return -EIO;
+       }
 
        for (i = 0; i < num_cards; i++) {
                mm_gendisk[i] = alloc_disk(1 << MM_SHIFT);
@@ -1207,6 +1209,7 @@ static int __init mm_init(void)
        return 0;
 
 out:
+       pci_unregister_driver(&mm_pci_driver);
        unregister_blkdev(major_nr, "umem");
        while (i--)
                put_disk(mm_gendisk[i]);