Re: Bug (?) in subsystem kset refcounts

From: Greg KH
Date: Sat Nov 08 2003 - 23:31:37 EST


On Sat, Nov 08, 2003 at 10:20:03PM -0500, Alan Stern wrote:
> I hesitate to say this is definitely a bug, since it might be intended
> behavior. But it is rather strange.
>
> Subsystems included an embedded kset, which itself includes an embedded
> kobject and so is subject to reference counting. Whenever a kobject
> belonging to the kset is destroyed, the kset's reference count is
> decremented. However, kobjects can be added to a kset via the three
> macros
>
> kobj_set_kset_s, kset_set_kset_s, and subsys_set_kset
>
> and these do _not_ increment the kset's reference count. As a result, the
> reference count only goes down, not up, quickly becoming negative.

See the patch that went into Linus's tree yesterday to fix where this
would happen.

But yes, usages of these macros is touchy, and we need to get it
correct. Your proposed patch will never allow the reference counts to
go back to zero.

Also, notice that when the kobject is initialized, the kset set by these
macros is then incremented.

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/