mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-15 23:25:07 +00:00
[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>
This commit is contained in:
parent
ea6f94dfe9
commit
dabad0568a
1 changed files with 23 additions and 9 deletions
|
@ -1157,6 +1157,7 @@ static int __init pc_init(void)
|
||||||
int crd;
|
int crd;
|
||||||
struct board_info *bd;
|
struct board_info *bd;
|
||||||
unsigned char board_id = 0;
|
unsigned char board_id = 0;
|
||||||
|
int err = -ENOMEM;
|
||||||
|
|
||||||
int pci_boards_found, pci_count;
|
int pci_boards_found, pci_count;
|
||||||
|
|
||||||
|
@ -1164,13 +1165,11 @@ static int __init pc_init(void)
|
||||||
|
|
||||||
pc_driver = alloc_tty_driver(MAX_ALLOC);
|
pc_driver = alloc_tty_driver(MAX_ALLOC);
|
||||||
if (!pc_driver)
|
if (!pc_driver)
|
||||||
return -ENOMEM;
|
goto out1;
|
||||||
|
|
||||||
pc_info = alloc_tty_driver(MAX_ALLOC);
|
pc_info = alloc_tty_driver(MAX_ALLOC);
|
||||||
if (!pc_info) {
|
if (!pc_info)
|
||||||
put_tty_driver(pc_driver);
|
goto out2;
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------
|
/* -----------------------------------------------------------------------
|
||||||
If epca_setup has not been ran by LILO set num_cards to defaults; copy
|
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)
|
||||||
|
|
||||||
} /* End for each card */
|
} /* End for each card */
|
||||||
|
|
||||||
if (tty_register_driver(pc_driver))
|
err = tty_register_driver(pc_driver);
|
||||||
panic("Couldn't register Digi PC/ driver");
|
if (err) {
|
||||||
|
printk(KERN_ERR "Couldn't register Digi PC/ driver");
|
||||||
|
goto out3;
|
||||||
|
}
|
||||||
|
|
||||||
if (tty_register_driver(pc_info))
|
err = tty_register_driver(pc_info);
|
||||||
panic("Couldn't register Digi PC/ info ");
|
if (err) {
|
||||||
|
printk(KERN_ERR "Couldn't register Digi PC/ info ");
|
||||||
|
goto out4;
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------
|
/* -------------------------------------------------------------------
|
||||||
Start up the poller to check for events on all enabled boards
|
Start up the poller to check for events on all enabled boards
|
||||||
|
@ -1385,6 +1390,15 @@ static int __init pc_init(void)
|
||||||
mod_timer(&epca_timer, jiffies + HZ/25);
|
mod_timer(&epca_timer, jiffies + HZ/25);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out4:
|
||||||
|
tty_unregister_driver(pc_driver);
|
||||||
|
out3:
|
||||||
|
put_tty_driver(pc_info);
|
||||||
|
out2:
|
||||||
|
put_tty_driver(pc_driver);
|
||||||
|
out1:
|
||||||
|
return err;
|
||||||
|
|
||||||
} /* End pc_init */
|
} /* End pc_init */
|
||||||
|
|
||||||
/* ------------------ Begin post_fep_init ---------------------- */
|
/* ------------------ Begin post_fep_init ---------------------- */
|
||||||
|
|
Loading…
Reference in a new issue