Re: [PATCH 2.6] Patch to hook up PPP to simple class sysfs support

From: Greg KH
Date: Wed Mar 10 2004 - 20:51:13 EST


On Wed, Mar 03, 2004 at 07:55:39PM -0800, Chris Wright wrote:
> * Hanna Linder (hannal@xxxxxxxxxx) wrote:
> > + ppp_class = class_simple_create(THIS_MODULE, "ppp");
> > + class_simple_device_add(ppp_class, MKDEV(PPP_MAJOR, 0), NULL, "ppp");
>
> What happens if that class_simple_create() fails? Actually,
> class_simple_device_add could fail too, but doesn't seem anybody is
> checking for that.
>
> > err = devfs_mk_cdev(MKDEV(PPP_MAJOR, 0),
> > S_IFCHR|S_IRUSR|S_IWUSR, "ppp");
> > - if (err)
> > + if (err) {
> > unregister_chrdev(PPP_MAJOR, "ppp");
> > + class_simple_device_remove(MKDEV(PPP_MAJOR,0));
> > + }
>
> need to destroy the class on error path to avoid leak.
>
> > @@ -2540,6 +2547,7 @@ static void __exit ppp_cleanup(void)
> > if (unregister_chrdev(PPP_MAJOR, "ppp") != 0)
> > printk(KERN_ERR "PPP: failed to unregister PPP device\n");
> > devfs_remove("ppp");
> > + class_simple_device_remove(MKDEV(PPP_MAJOR, 0));
>
> ditto. this will leak and would cause oops on reload of module.
>
> something like below.

Applied, thanks.

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/