Am Donnerstag, 24. Oktober 2002 00:19 schrieb David Brownell: > > 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); > > More like: > > 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.
The exact nature of the lock is of little significance. Sorry if that's the source of confusion. I was thinking of a semaphore because the initial idea was taking it around synchronous helpers as well, which cannot use a spinlock. The important thing is that the locking cannot be shifted into usbcore as I'd like to do, and that automatic unlinking of urbs by usbcore must happen after driver->disconnect(). I'd like to gather as much common code as possible. Thus this frustrates me. Regards Oliver ------------------------------------------------------- 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