diff mbox

[19/20] usb: host: xhci: check CLEAR_TOGGLE earlier

Message ID 20180416122930.15697-19-felipe.balbi@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Felipe Balbi April 16, 2018, 12:29 p.m. UTC
There's not need to delay check for CLEAR_TOGGLE until after we have
allocated urbpriv. Let's move it earlier and, finally, remove the
free_priv goto label.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
 drivers/usb/host/xhci.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index bff4f506035d..0fab051f06fc 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1329,6 +1329,11 @@  static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 	ep_index = xhci_get_endpoint_index(&urb->ep->desc);
 	ep_state = xhci->devs[slot_id]->eps[ep_index].ep_state;
 
+	if (ep_state & EP_SOFT_CLEAR_TOGGLE) {
+		xhci_warn(xhci, "Can't enqueue URB while manually clearing toggle\n");
+		return -EINVAL;
+	}
+
 	if (usb_endpoint_xfer_control(&urb->ep->desc)) {
 		/* Check to see if the max packet size for the default control
 		 * endpoint changed during FS device enumeration
@@ -1354,13 +1359,6 @@  static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 	trace_xhci_urb_enqueue(urb);
 
 	spin_lock_irqsave(&xhci->lock, flags);
-
-	if (ep_state & EP_SOFT_CLEAR_TOGGLE) {
-		xhci_warn(xhci, "Can't enqueue URB while manually clearing toggle\n");
-		ret = -EINVAL;
-		goto free_priv;
-	}
-
 	switch (usb_endpoint_type(&urb->ep->desc)) {
 	case USB_ENDPOINT_XFER_CONTROL:
 		ret = xhci_queue_ctrl_tx(xhci, GFP_ATOMIC, urb,
@@ -1380,7 +1378,6 @@  static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
 	}
 
 	if (ret) {
-free_priv:
 		xhci_urb_free_priv(urb_priv);
 		urb->hcpriv = NULL;
 	}