Messages in this thread | | | Date | Fri, 25 May 2012 08:33:35 +0800 | Subject | Re: Race condition between driver probe device and d evice shutdown | From | Ming Lei <> |
| |
On Thu, May 24, 2012 at 10:37 PM, Alan Stern <stern@rowland.harvard.edu> wrote: > > The code there is racy already. It does: > > } else if (dev->driver && dev->driver->shutdown) { > > without any locking protection. If the driver is unbound while this > statement runs then dev->driver could be non-NULL for the first test > and NULL for the second.
Yes, I missed this one, :-)
> >> > to fix the race by prevent driver core from probing or releasing once >> > shutdown is started. >> > >> > How about the below patch? >> >> How about waiting for the original poster to respond as to exactly how >> they are hitting this race before doing anything? > > In addition, the patch is too complicated. For this type of > synchronization you should use SRCU. See > Documentation/RCU/whatisRCU.txt and related files.
Yes, the synchronization should be a many reader vs. one writer problem, RCU should be suitable.
Looks we think alike, :-)
I have studied RCU yesterday, but was afraid that may introduce much more code, so not applied it in the patch. Will study it further to figure out a new version.
Thanks, -- Ming Lei -- 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/
| |