Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH v2 2/4] USB: cdc-acm: handle broken union descriptors
       [not found] <20200921135951.24045-1-johan@kernel.org>
@ 2020-09-21 13:59 ` Johan Hovold
  2020-09-22  9:53   ` <Daniel Caujolle-Bert>
  0 siblings, 1 reply; 2+ messages in thread
From: Johan Hovold @ 2020-09-21 13:59 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Greg Kroah-Hartman, linux-usb, Daniel Caujolle-Bert, Johan Hovold,
	stable

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.

Link: https://lore.kernel.org/r/5f4ca4f8.1c69fb81.a4487.0f5f@mx.google.com
Reported-by: Daniel Caujolle-Bert <f1rmb.daniel@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/class/cdc-acm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index e28ac640ff9c..f42ade505569 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1240,9 +1240,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) {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 2/4] USB: cdc-acm: handle broken union descriptors
  2020-09-21 13:59 ` [PATCH v2 2/4] USB: cdc-acm: handle broken union descriptors Johan Hovold
@ 2020-09-22  9:53   ` <Daniel Caujolle-Bert>
  0 siblings, 0 replies; 2+ messages in thread
From: <Daniel Caujolle-Bert> @ 2020-09-22  9:53 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Oliver Neukum, Greg Kroah-Hartman, linux-usb,
	Daniel Caujolle-Bert, stable

Tested-by: Daniel Caujolle-Bert <f1rmb.daniel@gmail.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-22  9:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20200921135951.24045-1-johan@kernel.org>
2020-09-21 13:59 ` [PATCH v2 2/4] USB: cdc-acm: handle broken union descriptors Johan Hovold
2020-09-22  9:53   ` <Daniel Caujolle-Bert>

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox