From: Peter Chen <peter.chen@nxp.com>
To: balbi@kernel.org, gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com, pawell@cadence.com,
rogerq@ti.com, jun.li@nxp.com, Peter Chen <peter.chen@nxp.com>,
stable@vger.kernel.org
Subject: [PATCH 3/3] usb: cdns3: ep0: add spinlock for cdns3_check_new_setup
Date: Tue, 23 Jun 2020 11:09:18 +0800 [thread overview]
Message-ID: <20200623030918.8409-4-peter.chen@nxp.com> (raw)
In-Reply-To: <20200623030918.8409-1-peter.chen@nxp.com>
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: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
drivers/usb/cdns3/ep0.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c
index 74a1ff5000ba..5aa69980e7ff 100644
--- a/drivers/usb/cdns3/ep0.c
+++ b/drivers/usb/cdns3/ep0.c
@@ -705,15 +705,17 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
int ret = 0;
u8 zlp = 0;
+ spin_lock_irqsave(&priv_dev->lock, flags);
trace_cdns3_ep0_queue(priv_dev, request);
/* 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;
+ }
/* send STATUS stage. Should be called only for SET_CONFIGURATION */
if (priv_dev->ep0_stage == CDNS3_STATUS_STAGE) {
- spin_lock_irqsave(&priv_dev->lock, flags);
cdns3_select_ep(priv_dev, 0x00);
erdy_sent = !priv_dev->hw_configured_flag;
@@ -738,7 +740,6 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
return 0;
}
- spin_lock_irqsave(&priv_dev->lock, flags);
if (!list_empty(&priv_ep->pending_req_list)) {
dev_err(priv_dev->dev,
"can't handle multiple requests for ep0\n");
--
2.17.1
next prev parent reply other threads:[~2020-06-23 3:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 3:09 [PATCH 0/3] usb: cdns3: bug-fixes for usb-linus Peter Chen
2020-06-23 3:09 ` [PATCH 1/3] usb: cdns3: ep0: fix the test mode set incorrectly Peter Chen
2020-06-23 6:45 ` Pawel Laszczak
2020-06-23 7:01 ` Peter Chen
2020-06-23 7:22 ` Pawel Laszczak
2020-06-23 3:09 ` [PATCH 2/3] usb: cdns3: trace: using correct dir value Peter Chen
2020-06-23 6:46 ` Pawel Laszczak
2020-06-23 3:09 ` Peter Chen [this message]
2020-06-23 6:46 ` [PATCH 3/3] usb: cdns3: ep0: add spinlock for cdns3_check_new_setup Pawel Laszczak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200623030918.8409-4-peter.chen@nxp.com \
--to=peter.chen@nxp.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jun.li@nxp.com \
--cc=linux-imx@nxp.com \
--cc=linux-usb@vger.kernel.org \
--cc=pawell@cadence.com \
--cc=rogerq@ti.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).