diff mbox series

usb: cdns3: removed useless condition in cdns3_gadget_ep_dequeue()

Message ID 20220711151032.16825-1-strochuk@ispras.ru
State New
Headers show
Series usb: cdns3: removed useless condition in cdns3_gadget_ep_dequeue() | expand

Commit Message

Andrey Strachuk July 11, 2022, 3:10 p.m. UTC
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(-)

Comments

Greg Kroah-Hartman July 14, 2022, 2:08 p.m. UTC | #1
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
Peter Chen July 16, 2022, 12:14 p.m. UTC | #2
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
>
diff mbox series

Patch

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