linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Greg KH <greg@kroah.com>
Cc: James Bottomley <James.Bottomley@SteelEye.com>,
	Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] driver core: better reference counting for klists
Date: Thu, 23 Feb 2006 22:32:42 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.0602232230440.19776-100000@netrider.rowland.org> (raw)
In-Reply-To: <20060224014204.GB25787@kroah.com>

On Thu, 23 Feb 2006, Greg KH wrote:

> On Thu, Feb 23, 2006 at 10:38:13AM -0500, Alan Stern wrote:
> > On Wed, 22 Feb 2006, Greg KH wrote:
> > 
> > > > Index: usb-2.6/drivers/base/dd.c
> > > > ===================================================================
> > > > --- usb-2.6.orig/drivers/base/dd.c
> > > > +++ usb-2.6/drivers/base/dd.c
> > > > @@ -72,6 +72,8 @@ int driver_probe_device(struct device_dr
> > > >  {
> > > >     int ret = 0;
> > > >     
> > > > +   if (!device_is_registered(dev))
> > > > +           return -ENODEV;
> > > >     if (drv->bus->match && !drv->bus->match(dev, drv))
> > > >             goto Done;
> > > >     
> > > > Index: usb-2.6/drivers/base/bus.c
> > > > ===================================================================
> > > > --- usb-2.6.orig/drivers/base/bus.c
> > > > +++ usb-2.6/drivers/base/bus.c
> > > > @@ -367,6 +367,7 @@ int bus_add_device(struct device * dev)
> > > >  
> > > >  	if (bus) {
> > > >  		pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
> > > > +		dev->is_registered = 1;
> > > >  		device_attach(dev);
> > > >  		klist_add_tail(&dev->knode_bus, &bus->klist_devices);
> > > >  		error = device_add_attrs(bus, dev);
> > > > @@ -393,7 +394,8 @@ void bus_remove_device(struct device * d
> > > >  		sysfs_remove_link(&dev->kobj, "bus");
> > > >  		sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
> > > >  		device_remove_attrs(dev->bus, dev);
> > > > -		klist_remove(&dev->knode_bus);
> > > > +		klist_del(&dev->knode_bus);
> > > > +		dev->is_registered = 0;
> > > 
> > > Don't we have a race between these two lines?  How is that protected?

> The last 2 ones above, doing a klist_del() and then after that setting
> is_registered to 0.

I don't understand the question.  The two lines are part of the same 
routine and they run in the same thread, so how can one race the other?

Alan Stern


      reply	other threads:[~2006-02-24  3:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-26 20:17 [PATCH] driver core: better reference counting for klists Alan Stern
2006-02-23  5:05 ` Greg KH
2006-02-23 15:38   ` Alan Stern
2006-02-24  1:42     ` Greg KH
2006-02-24  3:32       ` Alan Stern [this message]

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=Pine.LNX.4.44L0.0602232230440.19776-100000@netrider.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=James.Bottomley@SteelEye.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).