Messages in this thread | | | Date | Thu, 3 Jan 2008 16:14:29 +0100 | From | Cornelia Huck <> | Subject | Re: [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 :))
| |