qlcnic: fix netdev notifier in error path
authorAmit Kumar Salecha <amit.salecha@qlogic.com>
Tue, 13 Jul 2010 20:33:33 +0000 (20:33 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 14 Jul 2010 20:54:16 +0000 (13:54 -0700)
netdev notifier are not unregistered if pci_register_driver fails.

Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/qlcnic/qlcnic_main.c

index 0fef8c3c553ff85a1e952ba7b59c754dfbf137d5..0995f90b0bac0a799ee65a05215870a3cffcf6d2 100644 (file)
@@ -3451,6 +3451,7 @@ static struct pci_driver qlcnic_driver = {
 
 static int __init qlcnic_init_module(void)
 {
+       int ret;
 
        printk(KERN_INFO "%s\n", qlcnic_driver_string);
 
@@ -3459,8 +3460,15 @@ static int __init qlcnic_init_module(void)
        register_inetaddr_notifier(&qlcnic_inetaddr_cb);
 #endif
 
+       ret = pci_register_driver(&qlcnic_driver);
+       if (ret) {
+#ifdef CONFIG_INET
+               unregister_inetaddr_notifier(&qlcnic_inetaddr_cb);
+               unregister_netdevice_notifier(&qlcnic_netdev_cb);
+#endif
+       }
 
-       return pci_register_driver(&qlcnic_driver);
+       return ret;
 }
 
 module_init(qlcnic_init_module);