aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/class/cdc-acm.c
diff options
context:
space:
mode:
authorJohan Hovold <[email protected]>2020-09-21 13:59:49 +0000
committerGreg Kroah-Hartman <[email protected]>2020-09-25 15:01:12 +0000
commit960c7339de27c6d6fec13b54880501c3576bb08d (patch)
treefefd02493c4c93631bd57d0f7a10d55c912c2d50 /drivers/usb/class/cdc-acm.c
parentRevert "cdc-acm: hardening against malicious devices" (diff)
downloadkernel-960c7339de27c6d6fec13b54880501c3576bb08d.tar.gz
kernel-960c7339de27c6d6fec13b54880501c3576bb08d.zip
USB: cdc-acm: handle broken union descriptors
Handle broken union functional descriptors where the master-interface doesn't exist or where its class is of neither Communication or Data type (as required by the specification) by falling back to "combined-interface" probing. Note that this still allows for handling union descriptors with switched interfaces. This specifically makes the Whistler radio scanners TRX series devices work with the driver without adding further quirks to the device-id table. Reported-by: Daniel Caujolle-Bert <[email protected]> Tested-by: Daniel Caujolle-Bert <[email protected]> Acked-by: Oliver Neukum <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
Diffstat (limited to 'drivers/usb/class/cdc-acm.c')
-rw-r--r--drivers/usb/class/cdc-acm.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 3b87e978d972..30137d1b0d8d 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1241,9 +1241,21 @@ static int acm_probe(struct usb_interface *intf,
}
}
} else {
+ int class = -1;
+
data_intf_num = union_header->bSlaveInterface0;
control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0);
data_interface = usb_ifnum_to_if(usb_dev, data_intf_num);
+
+ if (control_interface)
+ class = control_interface->cur_altsetting->desc.bInterfaceClass;
+
+ if (class != USB_CLASS_COMM && class != USB_CLASS_CDC_DATA) {
+ dev_dbg(&intf->dev, "Broken union descriptor, assuming single interface\n");
+ combined_interfaces = 1;
+ control_interface = data_interface = intf;
+ goto look_for_collapsed_interface;
+ }
}
if (!control_interface || !data_interface) {