[PATCH] serial.c: get rid of panic in rs_init

From: Arnaldo Carvalho de Melo (acme@conectiva.com.br)
Date: Sat Aug 26 2000 - 17:25:02 EST


Ted,
        
        Please take a look and consider applying.

                        - Arnaldo

--- linux-2.4.0-test7/drivers/char/serial.c Thu Aug 24 07:39:57 2000
+++ linux-2.4.0-test7.acme/drivers/char/serial.c Sat Aug 26 19:22:31 2000
@@ -54,6 +54,9 @@
  * 7/00: fix some returns on failure not using MOD_DEC_USE_COUNT.
  * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  *
+ * 8/00: get rid of panic in rs_init
+ * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ *
  * This module exports the following rs232 io functions:
  *
  * int rs_init(void);
@@ -5094,7 +5097,7 @@
  */
 static int __init rs_init(void)
 {
- int i;
+ int i, ret;
         struct serial_state * state;
 
         init_bh(SERIAL_BH, do_serial_bh);
@@ -5191,10 +5194,16 @@
         callout_driver.proc_entry = 0;
 #endif
 
- if (tty_register_driver(&serial_driver))
- panic("Couldn't register serial driver\n");
- if (tty_register_driver(&callout_driver))
- panic("Couldn't register callout driver\n");
+ ret = tty_register_driver(&serial_driver);
+ if (ret) {
+ printk(KERN_ERR "Couldn't register serial driver\n");
+ return ret;
+ }
+ ret = tty_register_driver(&callout_driver);
+ if (ret) {
+ printf(KERN_ERR "Couldn't register callout driver\n");
+ goto cleanup_serial_driver;
+ }
         
         for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
                 state->magic = SSTATE_MAGIC;
@@ -5242,6 +5251,11 @@
        probe_serial_pnp();
 #endif
         return 0;
+cleanup_serial_driver:
+ i = tty_unregister_driver(&serial_driver);
+ if (i)
+ printk("serial: failed to unregister serial driver (%d)\n", i);
+ return ret;
 }
 
 /*
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 31 2000 - 21:00:18 EST