From: Bartlomiej Zolnierkiewicz Date: Tue, 5 Nov 2013 11:37:00 +0000 (+0100) Subject: skd: fix error paths in skd_init() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2b91c55222a0b2381e12328ca8cc60e6a823a998;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git skd: fix error paths in skd_init() Cc: Akhil Bhansali Cc: Jeff Moyer Signed-off-by: Bartlomiej Zolnierkiewicz Signed-off-by: Kyungmin Park Signed-off-by: Jens Axboe --- diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index 6f09bca3a24f..8c96d182601d 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c @@ -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)