usb: cdns3: removed useless condition in cdns3_gadget_ep_dequeue()
Subsystems (2)
PATCH 1/1 usb: cdns3: removed useless condition in cdns3_gadget_ep_dequeue()
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.
--- drivers/usb/cdns3/cdns3-gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/cdns3/cdns3-gadget.c +1 -1
@@ -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);
Signature · 1 line
2.25.1
Greg Kroah-Hartman
maintainerQuoted 3 lines · Andrey Strachuk
Comparison of 'ep' with NULL is useless since 'ep' is a result of
container_ofand 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
maintainerQuoted 4 lines · Andrey Strachuk
Comparison of 'ep' with NULL is useless since 'ep' is a result of
container_ofand 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
Quoted 25 lines
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by Andrey Strachuk <[email protected]>Fixes 64b558f597d1 ("usb: cdns3: Change file names for cdns3 driver.")--- drivers/usb/cdns3/cdns3-gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/cdns3/cdns3-gadget.c +1
-1@@ -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);Signature · 1 line
2.25.1
Signature · 2 lines
Thanks, Peter Chen