Skip to content

Commit

Permalink
staging: panel: fix error path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kulikov Vasiliy authored and Greg Kroah-Hartman committed Aug 3, 2010
1 parent d49d0e3 commit 10f3f5b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions drivers/staging/panel/panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -2124,26 +2124,42 @@ 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
* generated at keypad init
*/
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)
Expand Down

0 comments on commit 10f3f5b

Please sign in to comment.