lkml.org 
[lkml]   [2004]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2.6] Patch to hook up PPP to simple class sysfs support
On Wed, Mar 03, 2004 at 07:55:39PM -0800, Chris Wright wrote:
> * Hanna Linder (hannal@us.ibm.com) 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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:01    [W:0.075 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site