From: Greg KH <greg@kroah.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: Question about (or bug in?) the kobject implementation
Date: Fri, 27 Feb 2004 11:48:55 -0800 [thread overview]
Message-ID: <20040227194855.GB10864@kroah.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0402250955090.790-100000@ida.rowland.org>
On Wed, Feb 25, 2004 at 10:05:37AM -0500, Alan Stern wrote:
> Is it supposed to be legal to repeatedly call kobject_add() and
> kobject_del() for the same kobject? That is, is
>
> kobject_add(&kobj);
> ...
> kobject_del(&kobj);
> ...
> kobject_add(&kobj);
> ...
> kobject_del(&kobj);
>
> supposed to work?
No.
> The API doesn't forbid it, and there's no apparent reason why it
> should be illegal.
We prevent race conditions in kobject_put() by saying "Don't do that!"
:)
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...
> Why would anyone want to do this, you ask? Well the USB subsystem does it
> already. Each USB device can have several configurations, only one of
> which is active at any time. Corresponding to each configuration is a set
> of struct devices, and they (together with their embedded kobjects) are
> allocated and initialized when the USB device is first detected. The
> struct devices are add()'ed and del()'ed as configurations are activated
> and deactivated, leading to just the sort of call sequence shown above.
Then we need to fix this.
thanks,
greg k-h
next prev parent reply other threads:[~2004-02-27 19:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-25 15:05 Alan Stern
2004-02-27 19:48 ` Greg KH [this message]
2004-02-27 20:06 ` Alan Stern
2004-02-27 20:17 ` Greg KH
2004-02-28 4:02 Alan Stern
2004-02-28 7:38 ` Michael Frank
2004-02-28 17:09 ` Alan Stern
2004-03-03 21:44 ` Greg KH
2004-03-03 22:11 ` Alan Stern
2004-03-03 22:16 ` 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=20040227194855.GB10864@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
all inboxes | Powered by JetHome®