diff --git a/driver/vhci_ude/vhci_ep.c b/driver/vhci_ude/vhci_ep.c index 8509553b..45462557 100644 --- a/driver/vhci_ude/vhci_ep.c +++ b/driver/vhci_ude/vhci_ep.c @@ -215,7 +215,13 @@ ep_configure(_In_ UDECXUSBDEVICE udev, _In_ WDFREQUEST req, _In_ PUDECX_ENDPOINT status = submit_req_select(vusb->ep_default, req, 1, params->NewConfigurationValue, 0, 0); break; case UdecxEndpointsConfigureTypeInterfaceSettingChange: - status = set_intf_for_ep(vusb, req, params); + /* + * When a device is being detached, set_intf for the invalidated device is avoided. + * Error status for set_intf seems to disturb detaching. + */ + if (!vusb->invalid) { + status = set_intf_for_ep(vusb, req, params); + } break; case UdecxEndpointsConfigureTypeEndpointsReleasedOnly: break; diff --git a/driver/vhci_ude/vhci_urbr.c b/driver/vhci_ude/vhci_urbr.c index 32728337..21c225dd 100644 --- a/driver/vhci_ude/vhci_urbr.c +++ b/driver/vhci_ude/vhci_urbr.c @@ -194,6 +194,12 @@ submit_urbr(purb_req_t urbr) WdfSpinLockAcquire(vusb->spin_lock); + if (vusb->invalid) { + WdfSpinLockRelease(vusb->spin_lock); + TRD(URBR, "failed to submit urbr: invalidated vusb"); + return STATUS_DEVICE_NOT_CONNECTED; + } + if (vusb->urbr_sent_partial || vusb->pending_req_read == NULL) { if (urbr->type == URBR_TYPE_URB) { status = WdfRequestMarkCancelableEx(urbr->req, urbr_cancelled);