From: Akinobu Mita Date: Mon, 25 Jun 2007 15:39:33 +0000 (+0900) Subject: [SCSI] sr: fix error handling in module_init X-Git-Tag: v2.6.23-rc1~1053^2~22 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da3962fe63eae4f490356cb54e4700eac752541b;p=linux-2.6 [SCSI] sr: fix error handling in module_init Sweep registered blkdev when scsi_register_driver has failed. Cc: Jens Axboe Signed-off-by: Akinobu Mita Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index f9a52af7f5..5143c89908 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -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)