Re: Question about (or bug in?) the kobject implementation

From: Greg KH
Date: Wed Mar 03 2004 - 17:20:51 EST


On Wed, Mar 03, 2004 at 05:11:02PM -0500, Alan Stern wrote:
> On Wed, 3 Mar 2004, Greg KH wrote:
>
> > On Fri, Feb 27, 2004 at 11:02:34PM -0500, Alan Stern wrote:
> > > We're actually discussing two different questions here.
> > >
> > > A. Is it okay to call kobject_add() after calling kobject_del() --
> > > this was my original question.
> >
> > No, this is not ok. It might happen to work, but it is not valid.
>
> I want to understand _why_ it is not valid. Can you explain please?
>
> From what you said earlier, I got the impression that calling _add() after
> _del() is illegal because it runs the risk that the refcount may be 0 and
> the object may be gone.

Yes, that is the risk.

> But if you have a separate valid reference, that can't happen. Would
> it be legal then, or is there more to it?

Hm, it probably would work, hence the current working USB code :)
But I really don't want to "special case" anything here. So it's easier
to say, "just don't do that".

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/