aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/epca.c
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2006-10-17 03:10:28 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-17 11:18:48 -0400
commitdabad0568a5935e9f4903f5fd1d8f22b1c7c88c7 (patch)
tree8f095cf80e83c01b3262451fc1c91b4ee22ff26f /drivers/char/epca.c
parentea6f94dfe9db4d19a39e774cfafa5c9428a9fdbc (diff)
[PATCH] epca: prevent panic on tty_register_driver() failure
Make epca fail on initialization failure instead of panic. Cc: "Digi International, Inc" <Eng.Linux@digi.com> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Alan Cox <alan@redhat.com> Acked-by: Scott Kilau <scottk@digi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/epca.c')
-rw-r--r--drivers/char/epca.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index c3f95583a120..706733c0b36a 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -1157,6 +1157,7 @@ static int __init pc_init(void)
1157 int crd; 1157 int crd;
1158 struct board_info *bd; 1158 struct board_info *bd;
1159 unsigned char board_id = 0; 1159 unsigned char board_id = 0;
1160 int err = -ENOMEM;
1160 1161
1161 int pci_boards_found, pci_count; 1162 int pci_boards_found, pci_count;
1162 1163
@@ -1164,13 +1165,11 @@ static int __init pc_init(void)
1164 1165
1165 pc_driver = alloc_tty_driver(MAX_ALLOC); 1166 pc_driver = alloc_tty_driver(MAX_ALLOC);
1166 if (!pc_driver) 1167 if (!pc_driver)
1167 return -ENOMEM; 1168 goto out1;
1168 1169
1169 pc_info = alloc_tty_driver(MAX_ALLOC); 1170 pc_info = alloc_tty_driver(MAX_ALLOC);
1170 if (!pc_info) { 1171 if (!pc_info)
1171 put_tty_driver(pc_driver); 1172 goto out2;
1172 return -ENOMEM;
1173 }
1174 1173
1175 /* ----------------------------------------------------------------------- 1174 /* -----------------------------------------------------------------------
1176 If epca_setup has not been ran by LILO set num_cards to defaults; copy 1175 If epca_setup has not been ran by LILO set num_cards to defaults; copy
@@ -1370,11 +1369,17 @@ static int __init pc_init(void)
1370 1369
1371 } /* End for each card */ 1370 } /* End for each card */
1372 1371
1373 if (tty_register_driver(pc_driver)) 1372 err = tty_register_driver(pc_driver);
1374 panic("Couldn't register Digi PC/ driver"); 1373 if (err) {
1374 printk(KERN_ERR "Couldn't register Digi PC/ driver");
1375 goto out3;
1376 }
1375 1377
1376 if (tty_register_driver(pc_info)) 1378 err = tty_register_driver(pc_info);
1377 panic("Couldn't register Digi PC/ info "); 1379 if (err) {
1380 printk(KERN_ERR "Couldn't register Digi PC/ info ");
1381 goto out4;
1382 }
1378 1383
1379 /* ------------------------------------------------------------------- 1384 /* -------------------------------------------------------------------
1380 Start up the poller to check for events on all enabled boards 1385 Start up the poller to check for events on all enabled boards
@@ -1385,6 +1390,15 @@ static int __init pc_init(void)
1385 mod_timer(&epca_timer, jiffies + HZ/25); 1390 mod_timer(&epca_timer, jiffies + HZ/25);
1386 return 0; 1391 return 0;
1387 1392
1393out4:
1394 tty_unregister_driver(pc_driver);
1395out3:
1396 put_tty_driver(pc_info);
1397out2:
1398 put_tty_driver(pc_driver);
1399out1:
1400 return err;
1401
1388} /* End pc_init */ 1402} /* End pc_init */
1389 1403
1390/* ------------------ Begin post_fep_init ---------------------- */ 1404/* ------------------ Begin post_fep_init ---------------------- */