Commit d0b78265 authored by Peter Chen's avatar Peter Chen Committed by Greg Kroah-Hartman

usb: cdns3: ep0: add spinlock for cdns3_check_new_setup

The other thread may access other endpoints when the cdns3_check_new_setup
is handling, add spinlock to protect it.

Fixes: 7733f6c3 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Cc: <stable@vger.kernel.org>
Reviewed-by: default avatarPawel Laszczak <pawell@cadence.com>
Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
Link: https://lore.kernel.org/r/20200623030918.8409-4-peter.chen@nxp.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 813072b6
...@@ -705,15 +705,17 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep, ...@@ -705,15 +705,17 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
int ret = 0; int ret = 0;
u8 zlp = 0; u8 zlp = 0;
spin_lock_irqsave(&priv_dev->lock, flags);
trace_cdns3_ep0_queue(priv_dev, request); trace_cdns3_ep0_queue(priv_dev, request);
/* cancel the request if controller receive new SETUP packet. */ /* cancel the request if controller receive new SETUP packet. */
if (cdns3_check_new_setup(priv_dev)) if (cdns3_check_new_setup(priv_dev)) {
spin_unlock_irqrestore(&priv_dev->lock, flags);
return -ECONNRESET; return -ECONNRESET;
}
/* send STATUS stage. Should be called only for SET_CONFIGURATION */ /* send STATUS stage. Should be called only for SET_CONFIGURATION */
if (priv_dev->ep0_stage == CDNS3_STATUS_STAGE) { if (priv_dev->ep0_stage == CDNS3_STATUS_STAGE) {
spin_lock_irqsave(&priv_dev->lock, flags);
cdns3_select_ep(priv_dev, 0x00); cdns3_select_ep(priv_dev, 0x00);
erdy_sent = !priv_dev->hw_configured_flag; erdy_sent = !priv_dev->hw_configured_flag;
...@@ -738,7 +740,6 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep, ...@@ -738,7 +740,6 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
return 0; return 0;
} }
spin_lock_irqsave(&priv_dev->lock, flags);
if (!list_empty(&priv_ep->pending_req_list)) { if (!list_empty(&priv_ep->pending_req_list)) {
dev_err(priv_dev->dev, dev_err(priv_dev->dev,
"can't handle multiple requests for ep0\n"); "can't handle multiple requests for ep0\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment