aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKulikov Vasiliy <segooon@gmail.com>2010-07-30 07:08:20 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-02 21:23:45 -0400
commit10f3f5b7f6d1faca62c746d1a4e85f7afba4d7d0 (patch)
tree0620435b3572497b7e59ce66dcd210bcec880ac7
parentd49d0e39a09209d0136c7da2a1a52e99af2d4656 (diff)
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>
-rw-r--r--drivers/staging/panel/panel.c22
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)
2124 NULL, 2124 NULL,
2125 /*PARPORT_DEV_EXCL */ 2125 /*PARPORT_DEV_EXCL */
2126 0, (void *)&pprt); 2126 0, (void *)&pprt);
2127 if (pprt == NULL) {
2128 pr_err("panel_attach(): port->number=%d parport=%d, "
2129 "parport_register_device() failed\n",
2130 port->number, parport);
2131 return;
2132 }
2127 2133
2128 if (parport_claim(pprt)) { 2134 if (parport_claim(pprt)) {
2129 printk(KERN_ERR 2135 printk(KERN_ERR
2130 "Panel: could not claim access to parport%d. " 2136 "Panel: could not claim access to parport%d. "
2131 "Aborting.\n", parport); 2137 "Aborting.\n", parport);
2132 return; 2138 goto err_unreg_device;
2133 } 2139 }
2134 2140
2135 /* must init LCD first, just in case an IRQ from the keypad is 2141 /* must init LCD first, just in case an IRQ from the keypad is
@@ -2137,13 +2143,23 @@ static void panel_attach(struct parport *port)
2137 */ 2143 */
2138 if (lcd_enabled) { 2144 if (lcd_enabled) {
2139 lcd_init(); 2145 lcd_init();
2140 misc_register(&lcd_dev); 2146 if (misc_register(&lcd_dev))
2147 goto err_unreg_device;
2141 } 2148 }
2142 2149
2143 if (keypad_enabled) { 2150 if (keypad_enabled) {
2144 keypad_init(); 2151 keypad_init();
2145 misc_register(&keypad_dev); 2152 if (misc_register(&keypad_dev))
2153 goto err_lcd_unreg;
2146 } 2154 }
2155 return;
2156
2157err_lcd_unreg:
2158 if (lcd_enabled)
2159 misc_deregister(&lcd_dev);
2160err_unreg_device:
2161 parport_unregister_device(pprt);
2162 pprt = NULL;
2147} 2163}
2148 2164
2149static void panel_detach(struct parport *port) 2165static void panel_detach(struct parport *port)