diff mbox series

[v2] usb: host: xhci: drop redundant checks

Message ID 4faac4cb-7940-9133-6255-ff9df13bf87d@omp.ru (mailing list archive)
State Accepted
Commit 133da4b470ecb1d696f07d18753cc482fa0b7580
Headers show
Series [v2] usb: host: xhci: drop redundant checks | expand

Commit Message

Sergey Shtylyov Feb. 8, 2022, 7:39 p.m. UTC
In xhci_endpoint_{disable|reset}() the expression '&vdev->eps[ep_index]'
just cannot be NULL, so the checks have no sense at all...

Found by Linux Verification Center (linuxtesting.org) with the SVACE static
analysis tool.

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo.

Changes in version 2:
- fixed up the function name in the patch sdescription.

 drivers/usb/host/xhci.c |    4 ----
 1 file changed, 4 deletions(-)

Comments

Mathias Nyman Feb. 9, 2022, 12:40 p.m. UTC | #1
On 8.2.2022 21.39, Sergey Shtylyov wrote:
> In xhci_endpoint_{disable|reset}() the expression '&vdev->eps[ep_index]'
> just cannot be NULL, so the checks have no sense at all...
> 
> Found by Linux Verification Center (linuxtesting.org) with the SVACE static
> analysis tool.
> 
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

True, adding this

Thanks
-Mathias
Sergey Shtylyov Feb. 9, 2022, 3:20 p.m. UTC | #2
On 2/9/22 3:40 PM, Mathias Nyman wrote:

>> In xhci_endpoint_{disable|reset}() the expression '&vdev->eps[ep_index]'
>> just cannot be NULL, so the checks have no sense at all...
>>
>> Found by Linux Verification Center (linuxtesting.org) with the SVACE static
>> analysis tool.
>>
>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
> True, adding this

   At least SVACE was good for smething. :-)

> Thanks
> -Mathias

MBR, Sergey
diff mbox series

Patch

Index: usb/drivers/usb/host/xhci.c
===================================================================
--- usb.orig/drivers/usb/host/xhci.c
+++ usb/drivers/usb/host/xhci.c
@@ -3150,8 +3150,6 @@  rescan:
 
 	ep_index = xhci_get_endpoint_index(&host_ep->desc);
 	ep = &vdev->eps[ep_index];
-	if (!ep)
-		goto done;
 
 	/* wait for hub_tt_work to finish clearing hub TT */
 	if (ep->ep_state & EP_CLEARING_TT) {
@@ -3209,8 +3207,6 @@  static void xhci_endpoint_reset(struct u
 		return;
 	ep_index = xhci_get_endpoint_index(&host_ep->desc);
 	ep = &vdev->eps[ep_index];
-	if (!ep)
-		return;
 
 	/* Bail out if toggle is already being cleared by a endpoint reset */
 	spin_lock_irqsave(&xhci->lock, flags);