diff options
author | Kulikov Vasiliy <segooon@gmail.com> | 2010-07-30 15:08:20 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-02 18:23:45 -0700 |
commit | 10f3f5b7f6d1faca62c746d1a4e85f7afba4d7d0 (patch) | |
tree | 0620435b3572497b7e59ce66dcd210bcec880ac7 /drivers/staging | |
parent | d49d0e39a09209d0136c7da2a1a52e99af2d4656 (diff) | |
download | blackbird-op-linux-10f3f5b7f6d1faca62c746d1a4e85f7afba4d7d0.tar.gz blackbird-op-linux-10f3f5b7f6d1faca62c746d1a4e85f7afba4d7d0.zip |
staging: panel: fix error path
panel_attach() poorly handles errors. On error unregister everything we
have registered.
Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Acked-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/panel/panel.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index aeca01c05e40..3221814a856e 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -2124,12 +2124,18 @@ static void panel_attach(struct parport *port) NULL, /*PARPORT_DEV_EXCL */ 0, (void *)&pprt); + if (pprt == NULL) { + pr_err("panel_attach(): port->number=%d parport=%d, " + "parport_register_device() failed\n", + port->number, parport); + return; + } if (parport_claim(pprt)) { printk(KERN_ERR "Panel: could not claim access to parport%d. " "Aborting.\n", parport); - return; + goto err_unreg_device; } /* must init LCD first, just in case an IRQ from the keypad is @@ -2137,13 +2143,23 @@ static void panel_attach(struct parport *port) */ if (lcd_enabled) { lcd_init(); - misc_register(&lcd_dev); + if (misc_register(&lcd_dev)) + goto err_unreg_device; } if (keypad_enabled) { keypad_init(); - misc_register(&keypad_dev); + if (misc_register(&keypad_dev)) + goto err_lcd_unreg; } + return; + +err_lcd_unreg: + if (lcd_enabled) + misc_deregister(&lcd_dev); +err_unreg_device: + parport_unregister_device(pprt); + pprt = NULL; } static void panel_detach(struct parport *port) |