Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Cc: <stable@vger.kernel.org>
Reviewed-by: Pawel Laszczak <pawell@cadence.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
Link: https://lore.kernel.org/r/20200623030918.8409-4-peter.chen@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Peter Chen and committed by
Greg Kroah-Hartman
d0b78265 813072b6

+4 -3
+4 -3
drivers/usb/cdns3/ep0.c
··· 705 705 int ret = 0; 706 706 u8 zlp = 0; 707 707 708 + spin_lock_irqsave(&priv_dev->lock, flags); 708 709 trace_cdns3_ep0_queue(priv_dev, request); 709 710 710 711 /* cancel the request if controller receive new SETUP packet. */ 711 - if (cdns3_check_new_setup(priv_dev)) 712 + if (cdns3_check_new_setup(priv_dev)) { 713 + spin_unlock_irqrestore(&priv_dev->lock, flags); 712 714 return -ECONNRESET; 715 + } 713 716 714 717 /* send STATUS stage. Should be called only for SET_CONFIGURATION */ 715 718 if (priv_dev->ep0_stage == CDNS3_STATUS_STAGE) { 716 - spin_lock_irqsave(&priv_dev->lock, flags); 717 719 cdns3_select_ep(priv_dev, 0x00); 718 720 719 721 erdy_sent = !priv_dev->hw_configured_flag; ··· 740 738 return 0; 741 739 } 742 740 743 - spin_lock_irqsave(&priv_dev->lock, flags); 744 741 if (!list_empty(&priv_ep->pending_req_list)) { 745 742 dev_err(priv_dev->dev, 746 743 "can't handle multiple requests for ep0\n");