From: Peter Chen <peter.chen@kernel.org>
To: Andrey Strachuk <strochuk@ispras.ru>
Cc: Pawel Laszczak <pawell@cadence.com>,
Roger Quadros <rogerq@kernel.org>,
Aswath Govindraju <a-govindraju@ti.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
ldv-project@linuxtesting.org
Subject: Re: [PATCH v2] usb: cdns3: change place of 'priv_ep' assignment in cdns3_gadget_ep_dequeue(), cdns3_gadget_ep_enable()
Date: Wed, 27 Jul 2022 16:39:56 +0800 [thread overview]
Message-ID: <20220727083956.GA269370@nchen-desktop> (raw)
In-Reply-To: <20220718160052.4188-1-strochuk@ispras.ru>
On 22-07-18 19:00:52, Andrey Strachuk wrote:
> If 'ep' is NULL, result of ep_to_cdns3_ep(ep) is invalid pointer
> and its dereference with priv_ep->cdns3_dev may cause 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 | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
> index 5c15c48952a6..aea5db0ec72d 100644
> --- a/drivers/usb/cdns3/cdns3-gadget.c
> +++ b/drivers/usb/cdns3/cdns3-gadget.c
> @@ -2285,13 +2285,14 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep,
> int val;
>
> 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) {
> dev_dbg(priv_dev->dev, "usbss: invalid parameters\n");
> return -EINVAL;
> }
> +
> + comp_desc = priv_ep->endpoint.comp_desc;
> + priv_dev = priv_ep->cdns3_dev;
>
> if (!desc->wMaxPacketSize) {
> dev_err(priv_dev->dev, "usbss: missing wMaxPacketSize\n");
> @@ -2600,7 +2601,7 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
> struct usb_request *request)
> {
> struct cdns3_endpoint *priv_ep = ep_to_cdns3_ep(ep);
> - struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
> + struct cdns3_device *priv_dev;
> struct usb_request *req, *req_temp;
> struct cdns3_request *priv_req;
> struct cdns3_trb *link_trb;
> @@ -2610,6 +2611,8 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
>
> if (!ep || !request || !ep->desc)
> return -EINVAL;
> +
> + priv_dev = priv_ep->cdns3_dev;
>
> spin_lock_irqsave(&priv_dev->lock, flags);
>
> --
Acked-by: Peter Chen <peter.chen@kernel.org>
--
Thanks,
Peter Chen
next prev parent reply other threads:[~2022-07-27 8:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-18 16:00 [PATCH v2] usb: cdns3: change place of 'priv_ep' assignment in cdns3_gadget_ep_dequeue(), cdns3_gadget_ep_enable() Andrey Strachuk
2022-07-27 8:39 ` Peter Chen [this message]
2022-07-27 9:03 ` [ldv-project] " Alexey Khoroshilov
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=20220727083956.GA269370@nchen-desktop \
--to=peter.chen@kernel.org \
--cc=a-govindraju@ti.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=rogerq@kernel.org \
--cc=strochuk@ispras.ru \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.