VirtualBox

Changeset 93993 in vbox


Ignore:
Timestamp:
Feb 28, 2022 6:28:04 PM (3 years ago)
Author:
vboxsync
Message:

Devices/USB: Fix crash introduced with r150219 when a USB device is detached while the roothub tries to queue an URB but can't find the device. Also cancel all in flight URBs after the device was removed from the lookup tables in order to prevent the roothub from queueing URBs simultaneously, bugref:10196

Location:
trunk/src/VBox/Devices/USB
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp

    r93989 r93993  
    411411    Assert(pDev->i16Port != -1);
    412412
    413     /* Cancel all in-flight URBs from this device. */
    414     vusbDevCancelAllUrbs(pDev, true);
    415 
    416413    /*
    417414     * Detach the device and mark the port as available.
     
    434431    }
    435432    RTCritSectLeave(&pThis->CritSectDevices);
     433
     434    /* Cancel all in-flight URBs from this device. */
     435    vusbDevCancelAllUrbs(pDev, true);
    436436
    437437    /* Free resources. */
     
    956956        pUrb->enmState = VUSBURBSTATE_REAPED;
    957957        pUrb->enmStatus = VUSBSTATUS_DNR;
    958         vusbUrbCompletionRh(pUrb);
     958        vusbUrbCompletionRhEx(pRh, pUrb);
    959959        rc = VINF_SUCCESS;
    960960    }
  • trunk/src/VBox/Devices/USB/VUSBInternal.h

    r93989 r93993  
    484484void vusbUrbCancelAsync(PVUSBURB pUrb, CANCELMODE mode);
    485485void vusbUrbRipe(PVUSBURB pUrb);
    486 void vusbUrbCompletionRh(PVUSBURB pUrb);
     486void vusbUrbCompletionRhEx(PVUSBROOTHUB pRh, PVUSBURB pUrb);
    487487int vusbUrbSubmitHardError(PVUSBURB pUrb);
    488 int vusbUrbErrorRh(PVUSBURB pUrb);
     488int vusbUrbErrorRhEx(PVUSBROOTHUB pRh, PVUSBURB pUrb);
    489489int vusbDevUrbIoThreadWakeup(PVUSBDEV pDev);
    490490int vusbDevUrbIoThreadCreate(PVUSBDEV pDev);
     
    578578    RTCritSectLeave(&pDev->CritSectAsyncUrbs);
    579579}
     580
     581
     582DECLINLINE(int) vusbUrbErrorRh(PVUSBURB pUrb)
     583{
     584    PVUSBDEV pDev = pUrb->pVUsb->pDev;
     585    PVUSBROOTHUB pRh = vusbDevGetRh(pDev);
     586    AssertPtrReturn(pRh, VERR_VUSB_DEVICE_NOT_ATTACHED);
     587
     588    return vusbUrbErrorRhEx(pRh, pUrb);
     589}
     590
     591
     592DECLINLINE(void) vusbUrbCompletionRh(PVUSBURB pUrb)
     593{
     594    PVUSBROOTHUB pRh = vusbDevGetRh(pUrb->pVUsb->pDev);
     595    AssertPtrReturnVoid(pRh);
     596
     597    vusbUrbCompletionRhEx(pRh, pUrb);
     598}
     599
    580600
    581601/** @def vusbUrbAssert
  • trunk/src/VBox/Devices/USB/VUSBUrb.cpp

    r93115 r93993  
    216216 * @returns true if it could be retried.
    217217 * @returns false if it should be completed with failure.
     218 * @param   pRh     The roothub the URB originated from.
    218219 * @param   pUrb    The URB in question.
    219220 */
    220 int vusbUrbErrorRh(PVUSBURB pUrb)
     221int vusbUrbErrorRhEx(PVUSBROOTHUB pRh, PVUSBURB pUrb)
    221222{
    222223    PVUSBDEV pDev = pUrb->pVUsb->pDev;
    223     PVUSBROOTHUB pRh = vusbDevGetRh(pDev);
    224     AssertPtrReturn(pRh, VERR_VUSB_DEVICE_NOT_ATTACHED);
    225224    LogFlow(("%s: vusbUrbErrorRh: pDev=%p[%s] rh=%p\n", pUrb->pszDesc, pDev, pDev->pUsbIns ? pDev->pUsbIns->pszName : "", pRh));
    226225    return pRh->pIRhPort->pfnXferError(pRh->pIRhPort, pUrb);
     
    230229 * Does URB completion on roothub level.
    231230 *
     231 * @param   pRh     The roothub the URB originated from.
    232232 * @param   pUrb    The URB to complete.
    233233 */
    234 void vusbUrbCompletionRh(PVUSBURB pUrb)
     234void vusbUrbCompletionRhEx(PVUSBROOTHUB pRh, PVUSBURB pUrb)
    235235{
    236236    LogFlow(("%s: vusbUrbCompletionRh: type=%s status=%s\n",
     
    249249            LogRel(("VUSB: Capturing URB completion event failed with %Rrc\n", rc));
    250250    }
    251 
    252     PVUSBROOTHUB pRh = vusbDevGetRh(pUrb->pVUsb->pDev);
    253     AssertPtrReturnVoid(pRh);
    254251
    255252    /* If there is a sniffer on the roothub record the completed URB there too. */
     
    365362        case VUSBXFERTYPE_BULK:
    366363            if (pUrb->enmStatus != VUSBSTATUS_OK)
    367                 vusbUrbErrorRh(pUrb);
     364                vusbUrbErrorRhEx(pRh, pUrb);
    368365            break;
    369366    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette