Skip to contentSkip to conversation

usb: host: xhci: make 'usec' parameter of xhci_handshake() *unsigned*

PATCH In review Sergey Shtylyov 2 participants 3 messages Feb 15, 2022 – Feb 16, 2022

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

PATCH 1/1 usb: host: xhci: make 'usec' parameter of xhci_handshake() *unsigned*

The negative timeouts hardly make sense, and the 'usec' parameter of xhci_handshake() gets assigned to a 'u64' typed local variable in readl_poll_timeout_atomic() anyways...

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.

 drivers/usb/host/xhci.c |    2 +-
 drivers/usb/host/xhci.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.c +1 -1
Index: usb/drivers/usb/host/xhci.c
===================================================================
@@ -65,7 +65,7 @@ static bool td_on_ring(struct xhci_td *t
  * handshake done).  There are two failure modes:  "usec" have passed (major
  * hardware flakeout), or the register reads as all-ones (hardware removed).
  */
-int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec)
+int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, unsigned int usec)
 {
 	u32	result;
 	int	ret;
drivers/usb/host/xhci.h +1 -1
Index: usb/drivers/usb/host/xhci.h
===================================================================
@@ -2083,7 +2083,7 @@ void xhci_free_container_ctx(struct xhci
 
 /* xHCI host controller glue */
 typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
-int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec);
+int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, unsigned int usec);
 void xhci_quiesce(struct xhci_hcd *xhci);
 int xhci_halt(struct xhci_hcd *xhci);
 int xhci_start(struct xhci_hcd *xhci);
#1 lore raw
Quoted 3 lines · Sergey Shtylyov

The negative timeouts hardly make sense, and the 'usec' parameter of xhci_handshake() gets assigned to a 'u64' typed local variable in readl_poll_timeout_atomic() anyways...

Then why not just make it a u64 instead of a unsigned int?

thanks,

greg k-h

#2 lore raw
Quoted 5 lines · Greg Kroah-Hartman
Quoted 3 lines

The negative timeouts hardly make sense, and the 'usec' parameter of xhci_handshake() gets assigned to a 'u64' typed local variable in readl_poll_timeout_atomic() anyways...

Then why not just make it a u64 instead of a unsigned int?

Because *unsigned int* is enough? :-)

Quoted 3 lines

thanks,

greg k-h

MBR, Sergey