[PATCH next] fixup! usb: xhci: reset endpoint on USB stall

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


usb: xhci: call dma_unmap_single in all error paths

A new early exit for stalled USB was added that resets the endpoint
before returning an error code to the caller.

This unintentionally happened before unmapping the buffer, which is

  usb2-0: Resetting EP 0...
  WARNING: dwc3 2f00000.usb@xxxxxxxxxx: from-device mapping 0xbdf96680+0xff: duplicate mapping

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
 drivers/usb/host/xhci-ring.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 5f68bc7c2f35..691d9c7463ad 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1045,15 +1045,16 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe,
 	record_transfer_result(udev, event, length);
-	if (udev->status == USB_ST_STALLED) {
-		reset_ep(udev, ep_index, timeout_ms);
-		return -EPIPE;
-	}
 	/* Invalidate buffer to make it available to usb-core */
 	if (length > 0)
 		dma_unmap_single(ctrl->host.hw_dev, map, length, direction);
+	if (udev->status == USB_ST_STALLED) {
+		reset_ep(udev, ep_index, timeout_ms);
+		return -EPIPE;
+	}
 	if (GET_COMP_CODE(le32_to_cpu(event->trans_event.transfer_len))
 			== COMP_SHORT_TX) {
 		/* Short data stage, clear up additional status stage event */

[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux