From: Greg KH <greg@kroah.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Question about (or bug in?) the kobject implementation
Date: Wed, 3 Mar 2004 13:44:31 -0800 [thread overview]
Message-ID: <20040303214431.GC32489@kroah.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0402272233330.4063-100000@netrider.rowland.org>
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
next prev parent reply other threads:[~2004-03-03 21:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-28 4:02 Question about (or bug in?) the kobject implementation Alan Stern
2004-02-28 7:38 ` Michael Frank
2004-02-28 17:09 ` Alan Stern
2004-03-03 21:44 ` Greg KH [this message]
2004-03-03 22:11 ` Alan Stern
2004-03-03 22:16 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2004-02-25 15:05 Alan Stern
2004-02-27 19:48 ` Greg KH
2004-02-27 20:06 ` Alan Stern
2004-02-27 20:17 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040303214431.GC32489@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox