Skip to contentSkip to conversation

usb: host: xhci: drop redundant checks

PATCH In review Sergey Shtylyov 2 participants 3 messages Feb 8, 2022 – Feb 9, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: host: xhci: drop redundant checks

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.

---
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(-)
drivers/usb/host/xhci.c +0 -4
Index: 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);
#1 lore raw
Quoted 7 lines · Sergey Shtylyov

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.

True, adding this

Thanks
-Mathias

#2 lore raw
Quoted 9 lines · Mathias Nyman
Quoted 7 lines

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.

True, adding this

At least SVACE was good for smething. :-)

Quoted 2 lines

Thanks
-Mathias

MBR, Sergey