PERFORCE change 107531 for review

Hans Petter Selasky hselasky at FreeBSD.org
Sun Oct 8 23:18:56 PDT 2006


http://perforce.freebsd.org/chv.cgi?CH=107531

Change 107531 by hselasky at hselasky_mini_itx on 2006/10/09 06:18:00

	ubser: Need to stop all transfers atomically at
	detach, else an outstanding clear stall transfer can
	call "usbd_transfer_start()" passing a NULL pointer.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb/ubser.c#8 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb/ubser.c#8 (text+ko) ====

@@ -355,14 +355,24 @@
 ubser_detach(device_t dev)
 {
 	struct ubser_softc *sc = device_get_softc(dev);
+	uint8_t n;
 
 	DPRINTF(sc, 0, "\n");
 
 	ucom_detach(sc->sc_ucom, sc->sc_numser);
 
-	/* "usbd_transfer_unsetup" will stop all active
-	 * USB transfers:
+	/* need to stop all transfers atomically,
+	 * hence when clear stall completes, it
+	 * might start other transfers !
 	 */
+	mtx_lock(&Giant);
+	for (n = 0; n < UBSER_TR_MAX; n++) {
+	    if (sc->sc_xfer[n]) {
+	        usbd_transfer_stop(sc->sc_xfer[n]);
+	    }
+	}
+	mtx_unlock(&Giant);
+
 	usbd_transfer_unsetup(sc->sc_xfer, UBSER_TR_MAX);
 
 	return 0;


More information about the p4-projects mailing list