From: akinobu.mita@gmail.com (Akinobu Mita)
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org, "Digi International, Inc" <Eng.Linux@digi.com>
Subject: [PATCH] epca: privent from panic on tty_register_driver() failure
Date: Mon, 9 Oct 2006 18:06:03 +0900 [thread overview]
Message-ID: <20061009090603.GA6278@localhost> (raw)
This patch makes 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>
drivers/char/epca.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
Index: work-fault-inject/drivers/char/epca.c
===================================================================
--- work-fault-inject.orig/drivers/char/epca.c 2006-10-09 15:06:32.000000000 +0900
+++ work-fault-inject/drivers/char/epca.c 2006-10-09 15:09:14.000000000 +0900
@@ -1160,6 +1160,7 @@ static int __init pc_init(void)
int crd;
struct board_info *bd;
unsigned char board_id = 0;
+ int err = -ENOMEM;
int pci_boards_found, pci_count;
@@ -1167,13 +1168,11 @@ static int __init pc_init(void)
pc_driver = alloc_tty_driver(MAX_ALLOC);
if (!pc_driver)
- return -ENOMEM;
+ goto out1;
pc_info = alloc_tty_driver(MAX_ALLOC);
- if (!pc_info) {
- put_tty_driver(pc_driver);
- return -ENOMEM;
- }
+ if (!pc_info)
+ goto out2;
/* -----------------------------------------------------------------------
If epca_setup has not been ran by LILO set num_cards to defaults; copy
@@ -1373,11 +1372,17 @@ static int __init pc_init(void)
} /* End for each card */
- if (tty_register_driver(pc_driver))
- panic("Couldn't register Digi PC/ driver");
+ err = tty_register_driver(pc_driver);
+ if (err) {
+ printk(KERN_ERR "Couldn't register Digi PC/ driver");
+ goto out3;
+ }
- if (tty_register_driver(pc_info))
- panic("Couldn't register Digi PC/ info ");
+ err = tty_register_driver(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
@@ -1388,6 +1393,15 @@ static int __init pc_init(void)
mod_timer(&epca_timer, jiffies + HZ/25);
return 0;
+out4:
+ tty_unregister_driver(pc_driver);
+out3:
+ put_tty_driver(pc_driver);
+out2:
+ put_tty_driver(pc_info);
+out1:
+ return err;
+
} /* End pc_init */
/* ------------------ Begin post_fep_init ---------------------- */
next reply other threads:[~2006-10-09 9:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-09 9:06 Akinobu Mita [this message]
2006-10-09 15:45 ` [PATCH] epca: privent from panic on tty_register_driver() failure Randy Dunlap
2006-10-10 3:01 ` Akinobu Mita
2006-10-12 11:13 ` Alan Cox
-- strict thread matches above, loose matches on Subject: below --
2006-10-12 22:31 [PATCH] epca: privent from panic on tty_register_driver()failure Kilau, Scott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061009090603.GA6278@localhost \
--to=akinobu.mita@gmail.com \
--cc=Eng.Linux@digi.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox