lkml.org 
[lkml]   [2004]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Question about (or bug in?) the kobject implementation
On Fri, Feb 27, 2004 at 11:02:34PM -0500, Alan Stern wrote:
> On Fri, 27 Feb 2004, Greg KH wrote:
>
> > Seriously, once kobject_del() is called, you can't safely call
> > kobject_get() anymore on that object.
> >
> > If you can think of a way we can implement this in the code to prevent
> > people from doing this, please send a patch. We've been getting by
> > without such a "safeguard" so far...
>
> The problem is unsolvable. Let me explain...
>
> 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.

> B. Can we prevent people from doing kobject_get() after the kobject's
> refcount has dropped to 0?

By saying, "you can not call kobject_get() on a object that you know is
released with kobject_del()". If you already have a valid reference,
you can always call kobject_get(). But once you call kobject_del() that
pointer you passed should not be passed to kobject_get() as it may now
be gone.

Does that help?

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: 2005-03-22 14:01    [W:0.087 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site