On 13/01/16(Wed) 20:55, James Hastings wrote:
> Update.
> 
> Check for usb devices with no subdevices before force detaching subdevs.

Good catch, I'd like to commit the diff below that should have the same
effect.  Note that disabling ugen(4) is not really supported, but the
same problem could arise under memory pressure.

Index: usb_subr.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/usb_subr.c,v
retrieving revision 1.118
diff -u -p -r1.118 usb_subr.c
--- usb_subr.c  24 Oct 2015 14:01:40 -0000      1.118
+++ usb_subr.c  14 Jan 2016 12:47:48 -0000
@@ -1382,8 +1382,10 @@ usbd_detach(struct usbd_device *dev, str
 
        usbd_deactivate(dev);
 
-       for (i = 0; dev->subdevs[i] != NULL; i++)
-               rv |= config_detach(dev->subdevs[i], DETACH_FORCE);
+       if (dev->ndevs > 0) {
+               for (i = 0; dev->subdevs[i] != NULL; i++)
+                       rv |= config_detach(dev->subdevs[i], DETACH_FORCE);
+       }
 
        if (rv == 0)
                usb_free_device(dev);

Reply via email to