From: Andrey Strachuk <strochuk@ispras.ru>
To: Peter Chen <peter.chen@kernel.org>
Cc: Andrey Strachuk <strochuk@ispras.ru>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Pawel Laszczak <pawell@cadence.com>,
Roger Quadros <rogerq@kernel.org>,
Aswath Govindraju <a-govindraju@ti.com>,
Felipe Balbi <felipe.balbi@linux.intel.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
ldv-project@linuxtesting.org
Subject: [PATCH v2] usb: cdns3: change place of NULL check in cdns3_gadget_ep_enable()
Date: Thu, 28 Jul 2022 19:30:14 +0300 [thread overview]
Message-ID: <20220728163014.247082-1-strochuk@ispras.ru> (raw)
In-Reply-To: <16589929667170@kroah.com>
If 'ep' is NULL, result of ep_to_cdns3_ep(ep) is invalid and
priv_ep->cdns3_dev causes panic.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Andrey Strachuk <strochuk@ispras.ru>
Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
---
drivers/usb/cdns3/cdns3-gadget.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index 5c15c48952a6..51de7457a3b8 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -2284,11 +2284,14 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep,
int ret = 0;
int val;
+ if (!ep)
+ return -EINVAL;
+
priv_ep = ep_to_cdns3_ep(ep);
priv_dev = priv_ep->cdns3_dev;
comp_desc = priv_ep->endpoint.comp_desc;
- if (!ep || !desc || desc->bDescriptorType != USB_DT_ENDPOINT) {
+ if (!desc || desc->bDescriptorType != USB_DT_ENDPOINT) {
dev_dbg(priv_dev->dev, "usbss: invalid parameters\n");
return -EINVAL;
}
--
2.25.1
next parent reply other threads:[~2022-07-28 16:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <16589929667170@kroah.com>
2022-07-28 16:30 ` Andrey Strachuk [this message]
2022-08-03 12:26 ` [PATCH v2] usb: cdns3: change place of NULL check in cdns3_gadget_ep_enable() Roger Quadros
2022-08-19 8:36 ` Greg Kroah-Hartman
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=20220728163014.247082-1-strochuk@ispras.ru \
--to=strochuk@ispras.ru \
--cc=a-govindraju@ti.com \
--cc=felipe.balbi@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=ldv-project@linuxtesting.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pawell@cadence.com \
--cc=peter.chen@kernel.org \
--cc=rogerq@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