On Sat, Feb 21, 2009 at 3:18 AM, Marcus Glocker <mgloc...@cvs.openbsd.org> wrote: > CVSROOT: /cvs > Module name: src > Changes by: mgloc...@cvs.openbsd.org 2009/02/21 01:18:13 > > Modified files: > sys/dev/usb : uvideo.c > > Log message: > Fix a kernel crash for bulk devices when closing the video stream; > We give the kthread loop a moment to recognize that bulk_running=0 > before we close the USB pipes. Otherwise it can happen that we close > the USB pipes before the kthread loop stopped.
This is still no guarantee. The USB thread may not have run yet. This is a good place to use workq. It's trivial to write a drain function and wait for it to finish.