How to cancel given URBs (that may be submitted earlier) so that I can be
sure that after a certain point the USB subsystem will not access them
again (to call usb_free_urb())?

The first try would be to call usb_unlink_urb() (synchronously), but this
checks for -EINPROGRESS and fails if the urb status is something else--in
particular, if the device was just unplugged, the urbs may still be on the
way, calling completion handler later, but usb_unlink_urb() fails, because
status is changed.

Looking in usb-skeleton.c, I see that it uses "completions" to wait until
the URB handler has been called, but what if something goes wrong and the
handler will never get called? I'd rather not to trust this, if possible,
and that looks a bit unnecessarily complicated too.

Also, I read pwc-if.c and ov511.c drivers it looks like they have a
bug--they call usb_unlink_urb() and then immediately after usb_free_urb()
but since the former doesn't guarantee that the URBs wouldn't be accessed
later, the access may go to already freed memory.

Searching mailing lists, I found a thread about "URB nuking on disconnect"
but I'm not sure if it applies here.


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to