Hi Merighi,

Would you please try compiling with the diff below and let me know if
you can still reproduce the crash?

Thanks,
Matthew

Index: uhci.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/uhci.c,v
retrieving revision 1.84
diff -u -p -r1.84 uhci.c
--- uhci.c      23 Oct 2010 15:42:09 -0000      1.84
+++ uhci.c      19 Nov 2010 22:56:30 -0000
@@ -2740,7 +2740,7 @@ uhci_remove_intr(uhci_softc_t *sc, uhci_
 usbd_status
 uhci_device_setintr(uhci_softc_t *sc, struct uhci_pipe *upipe, int ival)
 {
-       uhci_soft_qh_t *sqh;
+       uhci_soft_qh_t *sqh, **qhs;
        int i, npoll, s;
        u_int bestbw, bw, bestoffs, offs;
 
@@ -2755,9 +2755,9 @@ uhci_device_setintr(uhci_softc_t *sc, st
        npoll = (UHCI_VFRAMELIST_COUNT + ival - 1) / ival;
        DPRINTFN(2, ("uhci_device_setintr: ival=%d npoll=%d\n", ival, npoll));
 
-       upipe->u.intr.npoll = npoll;
-       upipe->u.intr.qhs =
-               malloc(npoll * sizeof(uhci_soft_qh_t *), M_USBHC, M_WAITOK);
+       qhs = malloc(npoll * sizeof(uhci_soft_qh_t *), M_USBHC, M_NOWAIT);
+       if (qhs == NULL)
+               return (USBD_NOMEM);
 
        /*
         * Figure out which offset in the schedule that has most
@@ -2775,12 +2775,22 @@ uhci_device_setintr(uhci_softc_t *sc, st
        DPRINTFN(1, ("uhci_device_setintr: bw=%d offs=%d\n", bestbw, bestoffs));
 
        for(i = 0; i < npoll; i++) {
-               upipe->u.intr.qhs[i] = sqh = uhci_alloc_sqh(sc);
+               sqh = uhci_alloc_sqh(sc);
+               if (sqh == NULL) {
+                       while (i > 0)
+                               uhci_free_sqh(sc, qhs[--i]);
+                       free(qhs, M_USBHC);
+                       return (USBD_NOMEM);
+               }
                sqh->elink = NULL;
                sqh->qh.qh_elink = htole32(UHCI_PTR_T);
                sqh->pos = MOD(i * ival + bestoffs);
+               qhs[i] = sqh;
        }
 #undef MOD
+
+       upipe->u.intr.npoll = npoll;
+       upipe->u.intr.qhs = qhs;
 
        s = splusb();
        /* Enter QHs into the controller data structures. */

Reply via email to