Re: [RFC] kobject/kset/ktype documentation and example code updated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2007-12-19 at 23:26 -0500, Alan Stern wrote:
> On Wed, 19 Dec 2007, Greg KH wrote:

> > associated with a kobject, then the parent for the kobject can be set to
> > NULL in the call to kobject_add() and then the kobject will be placed under
> > the kset itself.
> 
> "and then the kobject's parent will be set to the kset itself."
> 
> Kay, in my version of kobject_add() it says:
> 
> 	if (kobj->kset) {
> 		kobj->kset = kset_get(kobj->kset);
> 
> 		if (!parent) {
> 			parent = kobject_get(&kobj->kset->kobj);
> 			/*
> 			 * If the kset is our parent, get a second
> 			 * reference, we drop both the kset and the
> 			 * parent ref on cleanup
> 			 */
> 			kobject_get(parent);
> 		}
> 
> That last call to kobject_get(parent) doesn't make sense.  The code has
> already taken two references to the kset: one in the assignment of
> kobj->kset and the other in the assignment of parent.  The final
> kobject_get() then acquires a third reference, which will never be
> dropped.

Yeah, that's wrong, and caused by two patches trying to solve the same
problem. We had users assigning the kset before kobject_init() and users
doing that after it. We moved the kset referencing from kobiect_init to
kobject_add, which introduced the third reference, while we already
added the second one to fix the issues. We could drop one of the patches
in the series, but this is all already gone with the latest changes in
Greg's tree.

Thanks,
Kay

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux