skd: fix error paths in skd_init()
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Tue, 5 Nov 2013 11:37:00 +0000 (12:37 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 8 Nov 2013 16:10:30 +0000 (09:10 -0700)
Cc: Akhil Bhansali <abhansali@stec-inc.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/skd_main.c

index 6f09bca3a24ff75194b68b3375bff1fbc3d62919..8c96d182601d9a35943675291aeda7df3d598745 100644 (file)
@@ -5396,7 +5396,7 @@ static void skd_log_skreq(struct skd_device *skdev,
 
 static int __init skd_init(void)
 {
-       int rc = 0;
+       int rc = -ENOMEM;
 
        pr_info(PFX " v%s-b%s loaded\n", DRV_VERSION, DRV_BUILD_ID);
 
@@ -5454,11 +5454,21 @@ static int __init skd_init(void)
        /* Obtain major device number. */
        rc = register_blkdev(0, DRV_NAME);
        if (rc < 0)
-               return rc;
+               goto err_register_blkdev;
 
        skd_major = rc;
 
-       return pci_register_driver(&skd_driver);
+       rc = pci_register_driver(&skd_driver);
+       if (rc < 0)
+               goto err_pci_register_driver;
+
+       return rc;
+
+err_pci_register_driver:
+       unregister_blkdev(skd_major, DRV_NAME);
+
+err_register_blkdev:
+       return rc;
 }
 
 static void __exit skd_exit(void)