* [PATCH] epca: privent from panic on tty_register_driver() failure
@ 2006-10-09 9:06 Akinobu Mita
2006-10-09 15:45 ` Randy Dunlap
2006-10-12 11:13 ` Alan Cox
0 siblings, 2 replies; 5+ messages in thread
From: Akinobu Mita @ 2006-10-09 9:06 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm, Digi International, Inc
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 ---------------------- */
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] epca: privent from panic on tty_register_driver() failure
2006-10-09 9:06 [PATCH] epca: privent from panic on tty_register_driver() failure Akinobu Mita
@ 2006-10-09 15:45 ` Randy Dunlap
2006-10-10 3:01 ` Akinobu Mita
2006-10-12 11:13 ` Alan Cox
1 sibling, 1 reply; 5+ messages in thread
From: Randy Dunlap @ 2006-10-09 15:45 UTC (permalink / raw)
To: Akinobu Mita; +Cc: linux-kernel, akpm, Digi International, Inc
On Mon, 9 Oct 2006 18:06:03 +0900 Akinobu Mita wrote:
> 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;
and then out2: uses pc_info, if it's NULL. Is that OK?
>
> /* -----------------------------------------------------------------------
> 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 ---------------------- */
> -
---
~Randy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] epca: privent from panic on tty_register_driver() failure
2006-10-09 15:45 ` Randy Dunlap
@ 2006-10-10 3:01 ` Akinobu Mita
0 siblings, 0 replies; 5+ messages in thread
From: Akinobu Mita @ 2006-10-10 3:01 UTC (permalink / raw)
To: Randy Dunlap; +Cc: linux-kernel, akpm, Digi International, Inc
On Mon, Oct 09, 2006 at 08:45:45AM -0700, Randy Dunlap wrote:
> >
> > 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;
>
> and then out2: uses pc_info, if it's NULL. Is that OK?
I made mistake. I swapped the order of these two put_tty_driver() in
error handling wrongly.
This is fixed version.
Subject: epca: privent from panic on tty_register_driver() failure
This patch 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>
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 22:16:24.000000000 +0900
+++ work-fault-inject/drivers/char/epca.c 2006-10-10 00:47:50.000000000 +0900
@@ -1157,6 +1157,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;
@@ -1164,13 +1165,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
@@ -1370,11 +1369,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
@@ -1385,6 +1390,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_info);
+out2:
+ put_tty_driver(pc_driver);
+out1:
+ return err;
+
} /* End pc_init */
/* ------------------ Begin post_fep_init ---------------------- */
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] epca: privent from panic on tty_register_driver() failure
2006-10-09 9:06 [PATCH] epca: privent from panic on tty_register_driver() failure Akinobu Mita
2006-10-09 15:45 ` Randy Dunlap
@ 2006-10-12 11:13 ` Alan Cox
1 sibling, 0 replies; 5+ messages in thread
From: Alan Cox @ 2006-10-12 11:13 UTC (permalink / raw)
To: Akinobu Mita; +Cc: linux-kernel, akpm, Digi International, Inc
Ar Llu, 2006-10-09 am 18:06 +0900, ysgrifennodd Akinobu Mita:
> 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>
Acked-by: Alan Cox <alan@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] epca: privent from panic on tty_register_driver()failure
@ 2006-10-12 22:31 Kilau, Scott
0 siblings, 0 replies; 5+ messages in thread
From: Kilau, Scott @ 2006-10-12 22:31 UTC (permalink / raw)
To: Alan Cox, Akinobu Mita; +Cc: linux-kernel, akpm, Eng.Linux
> Ar Llu, 2006-10-09 am 18:06 +0900, ysgrifennodd Akinobu Mita:
> > 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>
>
> Acked-by: Alan Cox <alan@redhat.com>
>
>
Acked-by: Scott Kilau <scottk@digi.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-10-12 22:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-09 9:06 [PATCH] epca: privent from panic on tty_register_driver() failure Akinobu Mita
2006-10-09 15:45 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox