lkml.org 
[lkml]   [2007]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] Sample kset/ktype/kobject implementation
On Thu, Nov 29, 2007 at 10:39:07AM +0100, Cornelia Huck wrote:
> On Wed, 28 Nov 2007 22:11:39 -0800,
> Greg KH <greg@kroah.com> wrote:
>
> > > > foo->kobj.kset = example_kset;
> > > > foo->kobj.ktype = &foo_ktype;
> > > >
> > > > /*
> > > > * Register the kobject with the kernel, all the default files will
> > > > * be created here and the uevent will be sent out. If we were to
> > > > * call kobject_init() and then kobject_add() we would be
> > > > * responsible for sending out the initial KOBJ_ADD uevent.
> > > > */
> > > > retval = kobject_register(&foo->kobj);
> > > > if (retval) {
> > > > kfree(foo);
> > >
> > > kobject_put(foo) is needed since it gets you through kobject_cleanup()
> > > where the name can be freed.
> >
> > No, kobject_register() should have handled that for us, right?
>
> kobject_register() doesn't do a kobject_put() if kobject_add() failed.

Crap. If I can't get this code right in an example, the API is messed
up. Time to take Kay seriously and start to revamp the basic kobject
api :)

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: 2007-11-29 21:49    [W:2.450 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site