On Thu, 1 Jul 2004, Luca Risolia wrote:

> On Thu, 1 Jul 2004 11:06:21 -0400 (EDT)
> Alan Stern <[EMAIL PROTECTED]> wrote:
> 
> > > It's worth to note that a number of drivers under usb/media/
> > > still implement "simple" urb removal (urb_unlink()+free_urb())
> > > without the above mechanism and proper error handling.
> > > Although this is not a problem in most of the cases, it is likely
> > > that they crash the kernel on SMP machines.
> > 
> > usb_unlink_urb() followed immediately by usb_free_urb() is correct, even 
> > if the unlink is asynchronous.  Reference counting of URBs guarantees that 
> > the URB won't be deallocated until the completion handler has finished 
> > running and the URB is idle.
> 
> Hmm..What if usb_unlink_urb() actually fails and you call usb_free_urb()
> despite of the error?

That's still correct.  As long as the USB core or the completion handler
is using the URB, its reference count will be greater than 0 so it won't
be freed.

A real error, by contrast, would be for a driver to call usb_free_urb()  
and then try to access or submit the URB.  Or to have usb_unlink_urb()  
fail and then try to access or submit the URB.  (Note that with the
usb_kill_urb() patch, it's impossible for synchronous usb_unlink_urb() to
fail.)

Alan Stern



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to