linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] usb: cdns3: change place of NULL check in cdns3_gadget_ep_enable()
       [not found] <16589929667170@kroah.com>
@ 2022-07-28 16:30 ` Andrey Strachuk
  2022-08-03 12:26   ` Roger Quadros
  2022-08-19  8:36   ` Greg Kroah-Hartman
  0 siblings, 2 replies; 3+ messages in thread
From: Andrey Strachuk @ 2022-07-28 16:30 UTC (permalink / raw)
  To: Peter Chen
  Cc: Andrey Strachuk, Greg Kroah-Hartman, Pawel Laszczak,
	Roger Quadros, Aswath Govindraju, Felipe Balbi, linux-usb,
	linux-kernel, ldv-project

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] usb: cdns3: change place of NULL check in cdns3_gadget_ep_enable()
  2022-07-28 16:30 ` [PATCH v2] usb: cdns3: change place of NULL check in cdns3_gadget_ep_enable() Andrey Strachuk
@ 2022-08-03 12:26   ` Roger Quadros
  2022-08-19  8:36   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 3+ messages in thread
From: Roger Quadros @ 2022-08-03 12:26 UTC (permalink / raw)
  To: Andrey Strachuk, Peter Chen
  Cc: Greg Kroah-Hartman, Pawel Laszczak, Aswath Govindraju,
	Felipe Balbi, linux-usb, linux-kernel, ldv-project



On 28/07/2022 19:30, Andrey Strachuk wrote:
> 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")

Acked-by: Roger Quadros <rogerq@kernel.org>

cheers,
-roger

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] usb: cdns3: change place of NULL check in cdns3_gadget_ep_enable()
  2022-07-28 16:30 ` [PATCH v2] usb: cdns3: change place of NULL check in cdns3_gadget_ep_enable() Andrey Strachuk
  2022-08-03 12:26   ` Roger Quadros
@ 2022-08-19  8:36   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2022-08-19  8:36 UTC (permalink / raw)
  To: Andrey Strachuk
  Cc: Peter Chen, Pawel Laszczak, Roger Quadros, Aswath Govindraju,
	Felipe Balbi, linux-usb, linux-kernel, ldv-project

On Thu, Jul 28, 2022 at 07:30:14PM +0300, Andrey Strachuk wrote:
> 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(-)

No information on what changed from v1 to v2 :(

> 
> 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;

How can ep ever be NULL at all?  Why does this need to be checked?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-19  8:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <16589929667170@kroah.com>
2022-07-28 16:30 ` [PATCH v2] usb: cdns3: change place of NULL check in cdns3_gadget_ep_enable() Andrey Strachuk
2022-08-03 12:26   ` Roger Quadros
2022-08-19  8:36   ` Greg Kroah-Hartman

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).