usb: xhci: Replace HCD_RH_RUNNING() check in xhci_stop_endpoint

This function can be called to stop an endpoint handled by the
secondary execution environment just after the HCD is removed
(e.g. Type-C cable removal), after which the QMI sound driver
proceeds to unmap transfer ring buffers from DMA. However,
although the RH state indicates it is not running, the controller
may not yet be fully halted and may continue to access now
unmapped memory. Replace the HCD_RH_RUNNING(hcd) check with
xhci_check_args() which includes a check for XHCI_STATE_HALTED,
so that a Stop command can still be issued.

Change-Id: Ie17882cdcfeea13fbdf7b1cd1353296d5966c798
Signed-off-by: Jack Pham <jackp@codeaurora.org>
This commit is contained in:
Jack Pham 2020-07-28 22:13:32 -07:00
commit e336888c91

View file

@ -5399,8 +5399,9 @@ int xhci_stop_endpoint(struct usb_device *udev, struct usb_host_endpoint *ep)
unsigned long flags;
int ret = 0;
if (!HCD_RH_RUNNING(hcd))
return 0;
ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
if (ret <= 0)
return ret;
cmd = xhci_alloc_command(xhci, true, GFP_NOIO);
if (!cmd)