| commit dcdaff7e78ec4647fdaa4892dd7fdc6b470ee491 |
| Author: Andrey Konovalov <andreyknvl@google.com> |
| Date: Wed Sep 27 17:06:15 2017 +0200 |
| |
| usb-fuzzer: dump usb device ids on enumeration |
| |
| diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c |
| index 8987cec9549d..166f2b6486af 100644 |
| --- a/drivers/usb/core/driver.c |
| +++ b/drivers/usb/core/driver.c |
| @@ -795,6 +795,19 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface, |
| } |
| EXPORT_SYMBOL_GPL(usb_match_id); |
| |
| +void usb_device_id_dump(const struct usb_device_id *id) |
| +{ |
| + for (; id->idVendor || id->idProduct || id->bDeviceClass || |
| + id->bInterfaceClass || id->driver_info; id++) { |
| + char buffer[128]; |
| + int size = (char *)&id->driver_info - (char *)id; |
| + bin2hex((char *)&buffer[0], (const char *)id, size); |
| + buffer[size * 2] = 0; |
| + pr_err("USBID: %s\n", &buffer[0]); |
| + } |
| +} |
| + |
| + |
| static int usb_device_match(struct device *dev, struct device_driver *drv) |
| { |
| /* devices and interfaces are handled separately */ |
| @@ -819,6 +832,9 @@ static int usb_device_match(struct device *dev, struct device_driver *drv) |
| intf = to_usb_interface(dev); |
| usb_drv = to_usb_driver(drv); |
| |
| + if (usb_drv->id_table != NULL) |
| + usb_device_id_dump(usb_drv->id_table); |
| + |
| id = usb_match_id(intf, usb_drv->id_table); |
| if (id) |
| return 1; |