Skip to content

Commit be8df02

Browse files
Peter ChenSasha Levin
authored andcommitted
usb: cdns3: ep0: add spinlock for cdns3_check_new_setup
commit 2587a02 upstream. The other thread may access other endpoints when the cdns3_check_new_setup is handling, add spinlock to protect it. Cc: <stable@vger.kernel.org> Fixes: 7733f6c ("usb: cdns3: Add Cadence USB3 DRD Driver") Reviewed-by: Pawel Laszczak <pawell@cadence.com> Signed-off-by: Peter Chen <peter.chen@nxp.com> Signed-off-by: Felipe Balbi <balbi@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a066865 commit be8df02

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/usb/cdns3/ep0.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,15 +712,17 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
712712
int ret = 0;
713713
u8 zlp = 0;
714714

715+
spin_lock_irqsave(&priv_dev->lock, flags);
715716
trace_cdns3_ep0_queue(priv_dev, request);
716717

717718
/* cancel the request if controller receive new SETUP packet. */
718-
if (cdns3_check_new_setup(priv_dev))
719+
if (cdns3_check_new_setup(priv_dev)) {
720+
spin_unlock_irqrestore(&priv_dev->lock, flags);
719721
return -ECONNRESET;
722+
}
720723

721724
/* send STATUS stage. Should be called only for SET_CONFIGURATION */
722725
if (priv_dev->ep0_stage == CDNS3_STATUS_STAGE) {
723-
spin_lock_irqsave(&priv_dev->lock, flags);
724726
cdns3_select_ep(priv_dev, 0x00);
725727

726728
erdy_sent = !priv_dev->hw_configured_flag;
@@ -745,7 +747,6 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
745747
return 0;
746748
}
747749

748-
spin_lock_irqsave(&priv_dev->lock, flags);
749750
if (!list_empty(&priv_ep->pending_req_list)) {
750751
dev_err(priv_dev->dev,
751752
"can't handle multiple requests for ep0\n");

0 commit comments

Comments
 (0)