Re: PCI driver module unload race?

Oliver Neukum
2003-03-10T23:38:54Z

> diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
> --- a/drivers/base/bus.c Mon Mar 10 13:52:15 2003
> +++ b/drivers/base/bus.c Mon Mar 10 13:52:15 2003
> @@ -263,14 +263,25 @@
> if (dev->bus->match(dev,drv)) {
> dev->driver = drv;
> if (drv->probe) {
> - if ((error = drv->probe(dev))) {

It seems that the semaphore in bus_add_device() makes this unnecessary.

[..]
> diff -Nru a/drivers/base/power.c b/drivers/base/power.c
> --- a/drivers/base/power.c Mon Mar 10 13:52:15 2003
> +++ b/drivers/base/power.c Mon Mar 10 13:52:15 2003
> @@ -41,10 +41,17 @@
> list_for_each(node,&devices_subsys.kset.list) {
> struct device * dev = to_dev(node);
> if (dev->driver && dev->driver->suspend) {
> - pr_debug("suspending device %s\n",dev->name);
> - error = dev->driver->suspend(dev,state,level);

This change is no good.
Either the semaphore protects you or it doesn't. If it doesn't you can't
even trust the dev pointer, because suspend() can sleep.

Regards
Oliver