mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] class_simple clean up in lp
@ 2004-03-04  3:58 Chris Wright
  2004-03-11  1:29 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Wright @ 2004-03-04  3:58 UTC (permalink / raw)
  To: greg; +Cc: linux-kernel

Error condition isn't caught on class_simple_create, and
parport_register_driver failure doesn't do proper cleanup.

===== drivers/char/lp.c 1.32 vs edited =====
--- 1.32/drivers/char/lp.c	Wed Mar  3 04:45:18 2004
+++ edited/drivers/char/lp.c	Wed Mar  3 19:32:56 2004
@@ -869,7 +869,7 @@
 
 int __init lp_init (void)
 {
-	int i;
+	int i, err = 0;
 
 	if (parport_nr[0] == LP_PARPORT_OFF)
 		return 0;
@@ -900,10 +900,15 @@
 
 	devfs_mk_dir("printers");
 	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)) {
 		printk (KERN_ERR "lp: unable to register with parport\n");
-		return -EIO;
+		err = -EIO;
+		goto out_class;
 	}
 
 	if (!lp_count) {
@@ -915,6 +920,13 @@
 	}
 
 	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)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] class_simple clean up in lp
  2004-03-04  3:58 [PATCH] class_simple clean up in lp Chris Wright
@ 2004-03-11  1:29 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2004-03-11  1:29 UTC (permalink / raw)
  To: Chris Wright; +Cc: linux-kernel

On Wed, Mar 03, 2004 at 07:58:32PM -0800, Chris Wright wrote:
> Error condition isn't caught on class_simple_create, and
> parport_register_driver failure doesn't do proper cleanup.

Applied, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-03-11  1:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-04  3:58 [PATCH] class_simple clean up in lp Chris Wright
2004-03-11  1:29 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®