[SCSI] sr: fix error handling in module_init
authorAkinobu Mita <akinobu.mita@gmail.com>
Mon, 25 Jun 2007 15:39:33 +0000 (00:39 +0900)
committerJames Bottomley <jejb@mulgrave.localdomain>
Sat, 14 Jul 2007 23:54:34 +0000 (18:54 -0500)
Sweep registered blkdev when scsi_register_driver has failed.

Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/sr.c

index f9a52af7f5b468a3fce49719b43606668f75d264..5143c899084523f3b9f47e67577757b6ce97a5ad 100644 (file)
@@ -885,7 +885,11 @@ static int __init init_sr(void)
        rc = register_blkdev(SCSI_CDROM_MAJOR, "sr");
        if (rc)
                return rc;
-       return scsi_register_driver(&sr_template.gendrv);
+       rc = scsi_register_driver(&sr_template.gendrv);
+       if (rc)
+               unregister_blkdev(SCSI_CDROM_MAJOR, "sr");
+
+       return rc;
 }
 
 static void __exit exit_sr(void)