Messages in this thread | | | Date | Mon, 15 Nov 2004 21:52:24 -0800 | From | Greg KH <> | Subject | Re: [PATCH 2.6.10-rc1 2/5] driver-model: bus_recan_devices() locking fix |
| |
On Tue, Nov 09, 2004 at 11:17:31PM -0500, Dmitry Torokhov wrote: > On Tuesday 09 November 2004 07:40 pm, Greg KH wrote: > > > I think we just have lay down the rules that one needs to get a reference > > > to an object in the following cases: > > > - object creation (first reference) > > > - linking some other object to the object in question. Every link to the > > > ? object should increase reference count. > > > - before passing object to another thread of execution to guarantee that > > > ? the object will live long enough for both threads. > > > > The rules are defined. ?See my OLS 2004 paper on krefs for details. > > > > So that means you will patches like the one below, right? > > diff -Nru a/drivers/base/driver.c b/drivers/base/driver.c > --- a/drivers/base/driver.c 2004-11-09 23:16:43 -05:00 > +++ b/drivers/base/driver.c 2004-11-09 23:16:43 -05:00 > @@ -26,13 +26,7 @@ > > int driver_create_file(struct device_driver * drv, struct driver_attribute * attr) > { > - int error; > - if (get_driver(drv)) { > - error = sysfs_create_file(&drv->kobj, &attr->attr); > - put_driver(drv); > - } else > - error = -EINVAL; > - return error; > + return sysfs_create_file(&drv->kobj, &attr->attr); > } > > > @@ -44,10 +38,7 @@ > > void driver_remove_file(struct device_driver * drv, struct driver_attribute * attr) > { > - if (get_driver(drv)) { > - sysfs_remove_file(&drv->kobj, &attr->attr); > - put_driver(drv); > - } > + sysfs_remove_file(&drv->kobj, &attr->attr); > }
While not totally necessary, the current code is safe :)
I'll ask Pat about this next time I see him.
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/
| |