diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2007-05-08 03:36:20 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:15:23 -0400 |
commit | 9dacf3b2f0cc657a5621e7f6d67ed27ce598f405 (patch) | |
tree | 59169bf14a537d984f3f38e5113352b8f952bcb0 /drivers/char/cyclades.c | |
parent | 14a55a6789d8409e58329310f9a18fc141deb4c2 (diff) |
Char: cyclades, cy_init error handling
- do not panic if tty_register_driver fails
- handle fail paths properly
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/cyclades.c')
-rw-r--r-- | drivers/char/cyclades.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 1fe0bb6c7ad7..970d99a69a2b 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c | |||
@@ -5460,10 +5460,11 @@ static const struct tty_operations cy_ops = { | |||
5460 | static int __init cy_init(void) | 5460 | static int __init cy_init(void) |
5461 | { | 5461 | { |
5462 | unsigned int i, nboards; | 5462 | unsigned int i, nboards; |
5463 | int retval = -ENOMEM; | ||
5463 | 5464 | ||
5464 | cy_serial_driver = alloc_tty_driver(NR_PORTS); | 5465 | cy_serial_driver = alloc_tty_driver(NR_PORTS); |
5465 | if (!cy_serial_driver) | 5466 | if (!cy_serial_driver) |
5466 | return -ENOMEM; | 5467 | goto err; |
5467 | show_version(); | 5468 | show_version(); |
5468 | 5469 | ||
5469 | /* Initialize the tty_driver structure */ | 5470 | /* Initialize the tty_driver structure */ |
@@ -5481,8 +5482,11 @@ static int __init cy_init(void) | |||
5481 | cy_serial_driver->flags = TTY_DRIVER_REAL_RAW; | 5482 | cy_serial_driver->flags = TTY_DRIVER_REAL_RAW; |
5482 | tty_set_operations(cy_serial_driver, &cy_ops); | 5483 | tty_set_operations(cy_serial_driver, &cy_ops); |
5483 | 5484 | ||
5484 | if (tty_register_driver(cy_serial_driver)) | 5485 | retval = tty_register_driver(cy_serial_driver); |
5485 | panic("Couldn't register Cyclades serial driver\n"); | 5486 | if (retval) { |
5487 | printk(KERN_ERR "Couldn't register Cyclades serial driver\n"); | ||
5488 | goto err_frtty; | ||
5489 | } | ||
5486 | 5490 | ||
5487 | for (i = 0; i < NR_CARDS; i++) { | 5491 | for (i = 0; i < NR_CARDS; i++) { |
5488 | /* base_addr=0 indicates board not found */ | 5492 | /* base_addr=0 indicates board not found */ |
@@ -5508,7 +5512,18 @@ static int __init cy_init(void) | |||
5508 | /* look for pci boards */ | 5512 | /* look for pci boards */ |
5509 | nboards += cy_detect_pci(); | 5513 | nboards += cy_detect_pci(); |
5510 | 5514 | ||
5511 | return nboards ? 0 : -ENODEV; | 5515 | if (nboards == 0) { |
5516 | retval = -ENODEV; | ||
5517 | goto err_unr; | ||
5518 | } | ||
5519 | |||
5520 | return 0; | ||
5521 | err_unr: | ||
5522 | tty_unregister_driver(cy_serial_driver); | ||
5523 | err_frtty: | ||
5524 | put_tty_driver(cy_serial_driver); | ||
5525 | err: | ||
5526 | return retval; | ||
5512 | } /* cy_init */ | 5527 | } /* cy_init */ |
5513 | 5528 | ||
5514 | static void __exit cy_cleanup_module(void) | 5529 | static void __exit cy_cleanup_module(void) |