More like:The problem is not NULL but a pointer to freed memory. The correct sequence in the driver is: down(mutex_with_disconnect); if (privat->device_is_still_present) usb_submit_urb(urb); up(mutex_with_disconnect);
submit (even in completion callbacks) by
grabbing driver lock
if device in driver state is null
status = fail
else
status = submit urb
if submit succeeded
store urb where disconnect will see it
release driver lock
disconnect by
grabbing driver lock
device handle in driver state = null
release driver lock
unlink all the submitted urbs, synchronous is simplest
... further cleanup
So no urb will ever be submitted (or resubmitted) after the
driver's disconnect() is called, and nobody's waltzing down
an invalid urb->dev pointer because the initial values stay
valid until disconnect() returns.
This shouldn't need to involve a semaphore, I don't know why
you keep going back to blocking primitives guarding submission
(which is commonly done in_interrupt); that should be a driver
policy choice. Sometimes a binary semaphore (mutex) will be
the right answer, other times it'll need to be a spinlock.
- Dave
-------------------------------------------------------
This sf.net email is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0002en
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel