VirtualBox

Changeset 104303 in vbox for trunk/src


Ignore:
Timestamp:
Apr 12, 2024 7:31:39 AM (10 months ago)
Author:
vboxsync
Message:

VUSB: Be more careful with what vusbR3RhGetVUsbDevByXxxRetain() returns.

File:
1 edited

Legend:

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

    r104125 r104303  
    11231123    PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort, "vusbRhAbortEpByPort");
    11241124
     1125    /* We expect to be called from a device like xHCI which keeps good track
     1126     * of device <--> port correspondence. Being called for a nonexistent
     1127     * device is an error.
     1128     */
     1129    AssertPtrReturn(pDev, VERR_INVALID_PARAMETER);
     1130
    11251131    if (pDev->pHub != pRh)
    11261132        AssertFailedReturn(VERR_INVALID_PARAMETER);
     
    11401146    PVUSBROOTHUB pRh = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
    11411147    PVUSBDEV pDev = vusbR3RhGetVUsbDevByAddrRetain(pRh, DstAddress, "vusbRhAbortEpByAddr");
     1148
     1149    /* We expect to be called from a device like OHCI which does not
     1150     * keep track of device <--> address correspondence and may try to
     1151     * cancel an address that does not correspond to a device. If there's
     1152     * no device, just do nothing.
     1153     */
     1154    if (!pDev)
     1155        return VINF_SUCCESS;
    11421156
    11431157    if (pDev->pHub != pRh)
     
    12351249    PVUSBROOTHUB    pRh = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
    12361250    AssertReturn(pRh, 0);
    1237     PVUSBDEV        pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort, "vusbRhUpdateIsocFrameDelta"); AssertPtr(pDev);
     1251    PVUSBDEV        pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort, "vusbRhUpdateIsocFrameDelta");
     1252    AssertPtrReturn(pDev, 0);
    12381253    PVUSBPIPE       pPipe = &pDev->aPipes[EndPt];
    12391254    uint32_t        *puLastFrame;
     
    12721287    PVUSBROOTHUB pThis = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
    12731288    PVUSBDEV     pDev  = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort, "vusbR3RhDevPowerOn");
    1274     AssertPtr(pDev);
     1289    AssertPtrReturn(pDev, VERR_VUSB_DEVICE_NOT_ATTACHED);
    12751290
    12761291    int rc = VUSBIDevPowerOn(&pDev->IDevice);
     
    12851300    PVUSBROOTHUB pThis = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
    12861301    PVUSBDEV     pDev  = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort, "vusbR3RhDevPowerOff");
    1287     AssertPtr(pDev);
     1302    AssertPtrReturn(pDev, VERR_VUSB_DEVICE_NOT_ATTACHED);
    12881303
    12891304    int rc = VUSBIDevPowerOff(&pDev->IDevice);
     
    12981313    PVUSBROOTHUB pThis = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
    12991314    PVUSBDEV     pDev  = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort, "vusbR3RhDevGetState");
    1300     AssertPtr(pDev);
     1315    AssertPtrReturn(pDev, VUSB_DEVICE_STATE_DETACHED);
    13011316
    13021317    VUSBDEVICESTATE enmState = VUSBIDevGetState(&pDev->IDevice);
     
    13111326    PVUSBROOTHUB pThis = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
    13121327    PVUSBDEV     pDev  = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort, "vusbR3RhDevIsSavedStateSupported");
    1313     AssertPtr(pDev);
     1328    AssertPtrReturn(pDev, false);
    13141329
    13151330    bool fSavedStateSupported = VUSBIDevIsSavedStateSupported(&pDev->IDevice);
     
    13241339    PVUSBROOTHUB pThis = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
    13251340    PVUSBDEV     pDev  = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort, "vusbR3RhDevGetSpeed");
    1326     AssertPtr(pDev);
     1341    AssertPtrReturn(pDev, VUSB_SPEED_UNKNOWN);
    13271342
    13281343    VUSBSPEED enmSpeed = pDev->IDevice.pfnGetSpeed(&pDev->IDevice);
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