lkml.org 
[lkml]   [2007]   [Nov]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] New kobject/kset/ktype documentation and example code
On Wed, Nov 28, 2007 at 05:09:50PM +0100, Cornelia Huck wrote:
> On Wed, 28 Nov 2007 17:03:07 +0100,
> Kay Sievers <kay.sievers@vrfy.org> wrote:
>
> > On Wed, 2007-11-28 at 16:52 +0100, Cornelia Huck wrote:
> > > On Wed, 28 Nov 2007 13:35:54 +0100,
> > > Kay Sievers <kay.sievers@vrfy.org> wrote:
> > >
> > > > On Wed, 2007-11-28 at 10:01 +0100, Cornelia Huck wrote:
> > > > > On Tue, 27 Nov 2007 15:02:52 -0800, Greg KH <greg@kroah.com> wrote:
> > > >
> > > > > > Among other things, kobject_init() sets the kobject's reference count to
> > > > > > one. Calling kobject_init() is not sufficient, however. Kobject users
> > > > > > must, at a minimum, set the name of the kobject; this is the name that will
> > > > > > be used in sysfs entries.
> > > > >
> > > > > Unless they don't register their kobject. (But they should always set a
> > > > > name anyway to avoid funny debug messages, so it is probably a good
> > > > > idea to call this a "must").
> > > >
> > > > Yeah, we should require it. And kobject_cleanup() needs to be called to
> > > > free the allocated name, if the object is not already added and needs to
> > > > be deleted (common in rewinding on error).
> > >
> > > Always using kobject_put() should take care of that.
> >
> > Ok, so we can always require a kobject_put() after a kobject_init(), to
> > cleanup what happened after _init() and before _add()?
>
> That's a sensible requirement, I think.

Yes, there are a few usages of unregistered kobjects in the kernel
today, but I think that was people just not realizing they could use a
simple kref instead. I'm working on cleaning them up right now...

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-28 18:37    [W:2.270 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site