ioc3/ioc4: fix error path on driver registration
authorJean Delvare <khali@linux-fr.org>
Tue, 15 Dec 2009 02:00:28 +0000 (18:00 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 15 Dec 2009 16:53:27 +0000 (08:53 -0800)
Two IOC3 and IOC4 drivers have broken error paths on registration.  Fix
them.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Pat Gefre <pfg@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/serial/ioc4_serial.c
drivers/sn/ioc3.c

index 902b067d7e9c770204d1f44aab967bb02afd9324..836d9ab4f729669ac11f941a3b3e246b367fdcb3 100644 (file)
@@ -2913,17 +2913,27 @@ static int __init ioc4_serial_init(void)
                printk(KERN_WARNING
                        "%s: Couldn't register rs232 IOC4 serial driver\n",
                        __func__);
-               return ret;
+               goto out;
        }
        if ((ret = uart_register_driver(&ioc4_uart_rs422)) < 0) {
                printk(KERN_WARNING
                        "%s: Couldn't register rs422 IOC4 serial driver\n",
                        __func__);
-               return ret;
+               goto out_uart_rs232;
        }
 
        /* register with IOC4 main module */
-       return ioc4_register_submodule(&ioc4_serial_submodule);
+       ret = ioc4_register_submodule(&ioc4_serial_submodule);
+       if (ret)
+               goto out_uart_rs422;
+       return 0;
+
+out_uart_rs422:
+       uart_unregister_driver(&ioc4_uart_rs422);
+out_uart_rs232:
+       uart_unregister_driver(&ioc4_uart_rs232);
+out:
+       return ret;
 }
 
 static void __exit ioc4_serial_exit(void)
index 354e9f17e35a1c6375c451408510cb2f0c59c90f..66802a4390ccff59bd51025dbb62800e6fd92336 100644 (file)
@@ -820,7 +820,7 @@ static int __init ioc3_init(void)
 {
        if (ia64_platform_is("sn2"))
                return pci_register_driver(&ioc3_driver);
-       return 0;
+       return -ENODEV;
 }
 
 /* Module unload */