Commit 717d3071 authored by Chris Wright's avatar Chris Wright Committed by Greg Kroah-Hartman

[PATCH] class_simple clean up in lp

Error condition isn't caught on class_simple_create, and
parport_register_driver failure doesn't do proper cleanup.
parent 21601e2e
...@@ -869,7 +869,7 @@ static struct parport_driver lp_driver = { ...@@ -869,7 +869,7 @@ static struct parport_driver lp_driver = {
int __init lp_init (void) int __init lp_init (void)
{ {
int i; int i, err = 0;
if (parport_nr[0] == LP_PARPORT_OFF) if (parport_nr[0] == LP_PARPORT_OFF)
return 0; return 0;
...@@ -900,10 +900,15 @@ int __init lp_init (void) ...@@ -900,10 +900,15 @@ int __init lp_init (void)
devfs_mk_dir("printers"); devfs_mk_dir("printers");
lp_class = class_simple_create(THIS_MODULE, "printer"); lp_class = class_simple_create(THIS_MODULE, "printer");
if (IS_ERR(lp_class)) {
err = PTR_ERR(lp_class);
goto out_devfs;
}
if (parport_register_driver (&lp_driver)) { if (parport_register_driver (&lp_driver)) {
printk (KERN_ERR "lp: unable to register with parport\n"); printk (KERN_ERR "lp: unable to register with parport\n");
return -EIO; err = -EIO;
goto out_class;
} }
if (!lp_count) { if (!lp_count) {
...@@ -915,6 +920,13 @@ int __init lp_init (void) ...@@ -915,6 +920,13 @@ int __init lp_init (void)
} }
return 0; return 0;
out_class:
class_simple_destroy(lp_class);
out_devfs:
devfs_remove("printers");
unregister_chrdev(LP_MAJOR, "lp");
return err;
} }
static int __init lp_init_module (void) static int __init lp_init_module (void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment