Re: [PATCH] driver core: better reference counting for klists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux