Skip to contentSkip to conversation

mtip32xx: fix error handling in mtip_init()

PATCH Applied Ryosuke Saito 2 participants 2 messages Apr 5, 2012 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtip32xx: fix error handling in mtip_init()

Sweep registered blkdev when pci_register_driver has failed.

---
 drivers/block/mtip32xx/mtip32xx.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +11 -4
index 8eb81c9..1000d19 100644
@@ -3608,18 +3608,25 @@ MODULE_DEVICE_TABLE(pci, mtip_pci_tbl);
  */
 static int __init mtip_init(void)
 {
+	int error;
+
 	printk(KERN_INFO MTIP_DRV_NAME " Version " MTIP_DRV_VERSION "\n");
 
 	/* Allocate a major block device number to use with this driver. */
-	mtip_major = register_blkdev(0, MTIP_DRV_NAME);
-	if (mtip_major < 0) {
+	error = register_blkdev(0, MTIP_DRV_NAME);
+	if (error <= 0) {
 		printk(KERN_ERR "Unable to register block device (%d)\n",
-		mtip_major);
+		error);
 		return -EBUSY;
 	}
+	mtip_major = error;
 
 	/* Register our PCI operations. */
-	return pci_register_driver(&mtip_pci_driver);
+	error = pci_register_driver(&mtip_pci_driver);
+	if (error)
+		unregister_blkdev(mtip_major, MTIP_DRV_NAME);
+
+	return error;
 }
 
 /*
Signature · 1 line
1.7.9.6
maintainer Applied
#1 lore raw
Quoted 1 line · Ryosuke Saito

Sweep registered blkdev when pci_register_driver has failed.

Thanks, applied.

Signature · 1 line
Jens Axboe