Skip to content

Commit

Permalink
more smooth cleanup for vusb for vhci(ude)
Browse files Browse the repository at this point in the history
If setting interface fails for a being detached device, vusb does not
be cleaned up. So, dynamic interface setting is avoided for an
invalidated device.
  • Loading branch information
cezanne committed Jan 10, 2021
1 parent b1d980a commit 862933f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion driver/vhci_ude/vhci_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions driver/vhci_ude/vhci_urbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 862933f

Please sign in to comment.