[PATCH] usbip: tools: fix wrong variable and double le16toh in list_gadget_devices
longlong yan <[email protected]>
| Newsgroups | org.kernel.vger.linux-usb,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
In list_gadget_devices(), the sprintf() call for idProduct_buf incorrectly
uses idVendor instead of idProduct due to a copy-paste mistake. This causes
the displayed product ID of vudc gadget devices to always show the vendor
ID instead.
Additionally, usbip_names_get_product() is called with le16toh() on
idVendor and idProduct values that were already converted from
little-endian to host byte order on the preceding lines. This double
conversion produces incorrect vendor/product IDs on big-endian
architectures, leading to wrong product name lookups.
Fixes: e0546fd8b748 ("usbip: tools: Start using VUDC backend in usbip tools")
Signed-off-by: longlong yan <[email protected]>
---
tools/usb/usbip/src/usbip_list.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/usb/usbip/src/usbip_list.c b/tools/usb/usbip/src/usbip_list.c
index 3d810bcca02f..85e6a8a1fc36 100644
--- a/tools/usb/usbip/src/usbip_list.c
+++ b/tools/usb/usbip/src/usbip_list.c
@@ -298,13 +298,12 @@ static int list_gadget_devices(bool parsable)
idVendor = le16toh(d_desc->idVendor);
sprintf(idVendor_buf, "0x%4x", idVendor);
idProduct = le16toh(d_desc->idProduct);
- sprintf(idProduct_buf, "0x%4x", idVendor);
+ sprintf(idProduct_buf, "0x%4x", idProduct);
busid = udev_device_get_sysname(dev);
/* Get product name. */
usbip_names_get_product(product_name, sizeof(product_name),
- le16toh(idVendor),
- le16toh(idProduct));
+ idVendor, idProduct);
/* Print information. */
print_device(busid, idVendor_buf, idProduct_buf, parsable);
--
2.43.0