lkml.org 
[lkml]   [2008]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] sample kset/ktype/kobject implementation code
On Wed, 19 Dec 2007 16:31:35 -0800,
Greg KH <greg@kroah.com> wrote:

> /*
> * Initialize and add the kobject to the kernel. All the default files
> * will be created here. As we have already specified a kset for this
> * kobject, we don't have to set a parent for the kobject, the kobject
> * will be placed beneath that kset automatically.
> */
> retval = kobject_init_and_add(&foo->kobj, &foo_ktype, NULL, "%s", name);
> if (retval) {
> kfree(foo);
> return NULL;
> }

I really hate to say this, but the example is still wrong. There needs
to be a kobject_put(&foo->kobj) instead of the kfree(foo) (as the
comments for kobject_init_and_add() resp. kobject_add_ng() correctly
explain :))


\
 
 \ /
  Last update: 2008-01-03 16:17    [W:0.169 / U:0.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site