Skip to content

Commit 3268082

Browse files
jhovoldgregkh
authored andcommitted
USB: cdc-acm: handle broken union descriptors
[ Upstream commit 960c733 ] 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 <f1rmb.daniel@gmail.com> Tested-by: Daniel Caujolle-Bert <f1rmb.daniel@gmail.com> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://lore.kernel.org/r/20200921135951.24045-3-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0a35951 commit 3268082

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/usb/class/cdc-acm.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,9 +1243,21 @@ static int acm_probe(struct usb_interface *intf,
12431243
}
12441244
}
12451245
} else {
1246+
int class = -1;
1247+
12461248
data_intf_num = union_header->bSlaveInterface0;
12471249
control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0);
12481250
data_interface = usb_ifnum_to_if(usb_dev, data_intf_num);
1251+
1252+
if (control_interface)
1253+
class = control_interface->cur_altsetting->desc.bInterfaceClass;
1254+
1255+
if (class != USB_CLASS_COMM && class != USB_CLASS_CDC_DATA) {
1256+
dev_dbg(&intf->dev, "Broken union descriptor, assuming single interface\n");
1257+
combined_interfaces = 1;
1258+
control_interface = data_interface = intf;
1259+
goto look_for_collapsed_interface;
1260+
}
12491261
}
12501262

12511263
if (!control_interface || !data_interface) {

0 commit comments

Comments
 (0)