aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-30 08:45:39 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-30 08:45:39 +0100
commitdb6b20ab8477005658ba62ba48fe7c60b7144cc6 (patch)
tree1c046aba0555600de249fc705f0a4ef631fc5fec
parent5148e86d09f9f1b1c44587d014e5bcee3bb8c26e (diff)
downloadusbutils-db6b20ab8477005658ba62ba48fe7c60b7144cc6.tar.gz
lsusb: fix up [unknown] vendor and product strings.
In commit 8a80f70a8afb ("names.c: if a string can not be found in the usb.ids file, return [unknown]"), the logic for determining the vendor and product for the USB device was changed to ONLY rely on the usb.ids file, instead of falling back to any vendor/product strings that are on the device itself. This had the bad side-affect of causing many devices that previously showed vendor/product information just fine, to now show up as [unknown]. Fix this up to fall back to looking at the string in the device itself, and ONLY if the string is not present, will '[unknown]' be printed out. This changes the output on one of my machines from: Bus 003 Device 002: ID 32ac:0002 [unknown] [unknown] to: Bus 003 Device 002: ID 32ac:0002 Framework HDMI Expansion Card This should resolve github issue #177, many thanks to the people reporting it quickly there. Fixes: 8a80f70a8afb ("names.c: if a string can not be found in the usb.ids file, return [unknown]") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--lsusb.c8
-rw-r--r--names.c4
2 files changed, 6 insertions, 6 deletions
diff --git a/lsusb.c b/lsusb.c
index 3172787..e06e79d 100644
--- a/lsusb.c
+++ b/lsusb.c
@@ -3624,11 +3624,11 @@ static void get_vendor_product_with_fallback(char *vendor, int vendor_len,
if (get_sysfs_name(sysfs_name, sizeof(sysfs_name), dev) >= 0) {
if (!have_vendor)
- read_sysfs_prop(vendor, vendor_len, sysfs_name,
- "manufacturer");
+ if (!read_sysfs_prop(vendor, vendor_len, sysfs_name, "manufacturer"))
+ strncpy(vendor, "[unknown]", vendor_len);
if (!have_product)
- read_sysfs_prop(product, product_len, sysfs_name,
- "product");
+ if (!read_sysfs_prop(product, product_len, sysfs_name, "product"))
+ strncpy(product, "[unknown]", product_len);
}
}
diff --git a/names.c b/names.c
index 1adb5a4..7ae1091 100644
--- a/names.c
+++ b/names.c
@@ -192,7 +192,7 @@ int get_vendor_string(char *buf, size_t size, uint16_t vid)
return 0;
*buf = 0;
if (!(cp = names_vendor(vid)))
- return snprintf(buf, size, "[unknown]");
+ return 0;
return snprintf(buf, size, "%s", cp);
}
@@ -204,7 +204,7 @@ int get_product_string(char *buf, size_t size, uint16_t vid, uint16_t pid)
return 0;
*buf = 0;
if (!(cp = names_product(vid, pid)))
- return snprintf(buf, size, "[unknown]");
+ return 0;
return snprintf(buf, size, "%s", cp);
}