All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: cdns3: removed useless condition in cdns3_gadget_ep_dequeue()
@ 2022-07-11 15:10 Andrey Strachuk
  2022-07-14 14:08 ` Greg Kroah-Hartman
  2022-07-16 12:14 ` Peter Chen
  0 siblings, 2 replies; 3+ messages in thread
From: Andrey Strachuk @ 2022-07-11 15:10 UTC (permalink / raw)
  To: Peter Chen
  Cc: Andrey Strachuk, Pawel Laszczak, Roger Quadros,
	Aswath Govindraju, Greg Kroah-Hartman, linux-usb, linux-kernel

Comparison of 'ep' with NULL is useless since
'ep' is a result of container_of and cannot be NULL
in any reasonable scenario.


Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Andrey Strachuk <strochuk@ispras.ru>
Fixes: 64b558f597d1 ("usb: cdns3: Change file names for cdns3 driver.")
---
 drivers/usb/cdns3/cdns3-gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index 5c15c48952a6..f31b389ae0b2 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -2608,7 +2608,7 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
 	unsigned long flags;
 	int ret = 0;
 
-	if (!ep || !request || !ep->desc)
+	if (!request || !ep->desc)
 		return -EINVAL;
 
 	spin_lock_irqsave(&priv_dev->lock, flags);
-- 
2.25.1


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

* Re: [PATCH] usb: cdns3: removed useless condition in cdns3_gadget_ep_dequeue()
  2022-07-11 15:10 [PATCH] usb: cdns3: removed useless condition in cdns3_gadget_ep_dequeue() Andrey Strachuk
@ 2022-07-14 14:08 ` Greg Kroah-Hartman
  2022-07-16 12:14 ` Peter Chen
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2022-07-14 14:08 UTC (permalink / raw)
  To: Andrey Strachuk
  Cc: Peter Chen, Pawel Laszczak, Roger Quadros, Aswath Govindraju,
	linux-usb, linux-kernel

On Mon, Jul 11, 2022 at 06:10:32PM +0300, Andrey Strachuk wrote:
> Comparison of 'ep' with NULL is useless since
> 'ep' is a result of container_of and cannot be NULL
> in any reasonable scenario.

ep is nto the result of container_of() in this driver, are you SURE this
is correct?

If so, please show the proper callstack where this is determined.

thanks,

greg k-h

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

* Re: [PATCH] usb: cdns3: removed useless condition in cdns3_gadget_ep_dequeue()
  2022-07-11 15:10 [PATCH] usb: cdns3: removed useless condition in cdns3_gadget_ep_dequeue() Andrey Strachuk
  2022-07-14 14:08 ` Greg Kroah-Hartman
@ 2022-07-16 12:14 ` Peter Chen
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Chen @ 2022-07-16 12:14 UTC (permalink / raw)
  To: Andrey Strachuk
  Cc: Pawel Laszczak, Roger Quadros, Aswath Govindraju,
	Greg Kroah-Hartman, linux-usb, linux-kernel

On 22-07-11 18:10:32, Andrey Strachuk wrote:
> Comparison of 'ep' with NULL is useless since
> 'ep' is a result of container_of and cannot be NULL
> in any reasonable scenario.
> 

If ep is NULL, the container_of(NULL, struct cdns3_endpoint,
endpoint) will not cause panic, but later ep->desc will cause panic.
So we can't delete the NULL check for ep.

Peter

> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Andrey Strachuk <strochuk@ispras.ru>
> Fixes: 64b558f597d1 ("usb: cdns3: Change file names for cdns3 driver.")
> ---
>  drivers/usb/cdns3/cdns3-gadget.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
> index 5c15c48952a6..f31b389ae0b2 100644
> --- a/drivers/usb/cdns3/cdns3-gadget.c
> +++ b/drivers/usb/cdns3/cdns3-gadget.c
> @@ -2608,7 +2608,7 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
>  	unsigned long flags;
>  	int ret = 0;
>  
> -	if (!ep || !request || !ep->desc)
> +	if (!request || !ep->desc)
>  		return -EINVAL;
>  
>  	spin_lock_irqsave(&priv_dev->lock, flags);
> -- 
> 2.25.1
> 

-- 

Thanks,
Peter Chen

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

end of thread, other threads:[~2022-07-16 12:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-11 15:10 [PATCH] usb: cdns3: removed useless condition in cdns3_gadget_ep_dequeue() Andrey Strachuk
2022-07-14 14:08 ` Greg Kroah-Hartman
2022-07-16 12:14 ` Peter Chen

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.