On Mon, 12 Jun 2006, Greg KH wrote:

> On Mon, Jun 12, 2006 at 03:16:31PM -0400, Alan Stern wrote:
> > Greg:
> > 
> > This patch (as712) fixes the usb-skeleton example driver so that it won't
> > try to submit URBs after skel_disconnect() has returned.  This could cause
> > errors, if the driver was unbound and then a different driver was bound to
> > the device.
> 
> Huh?  How could that happen?  Ah, the struct usb_device would be now
> owned by another driver...
> 
> Ick.
> 
> Yeah, I guess this patch is needed, oh well, maybe I'll think of some
> other way to do this without a lock being needed...  I just want to keep
> it simple wherever possible...

I sympathize with the desire to keep things simple.  In this case the 
extra mutex wasn't really needed; the regular usb_device lock could have 
been used instead.  But that lock controls other things; it wouldn't be 
friendly to hog it in a multi-interface device, for example.  And even 
then, you would still need to explicitly acquire and release the lock.

I don't think there _is_ any way to fix this without some sort of 
synchronization mechanism.  The race between read/write and disconnect 
makes it unavoidable.  A mutex seemed like the simplest solution.

Alan Stern



_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to