Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

uapi: cdc.h: cleanly provide for more interfaces and countries

The spec requires at least one interface respectively country.
It allows multiple ones. This needs to be clearly said in the UAPI.
This is subject to sanity checking in cdc_parse_cdc_header(), thus
we can trust the length.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Link: https://patch.msgid.link/20251111134641.4118827-1-oneukum@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Oliver Neukum and committed by
Greg Kroah-Hartman
a67df6d1 8d3c283e

+9 -5
+1 -1
drivers/usb/class/cdc-acm.c
··· 1475 1475 if (!acm->country_codes) 1476 1476 goto skip_countries; 1477 1477 acm->country_code_size = cfd->bLength - 4; 1478 - memcpy(acm->country_codes, (u8 *)&cfd->wCountyCode0, 1478 + memcpy(acm->country_codes, cfd->wCountryCodes, 1479 1479 cfd->bLength - 4); 1480 1480 acm->country_rel_date = cfd->iCountryCodeRelDate; 1481 1481
+8 -4
include/uapi/linux/usb/cdc.h
··· 104 104 __u8 bDescriptorSubType; 105 105 106 106 __u8 bMasterInterface0; 107 - __u8 bSlaveInterface0; 108 - /* ... and there could be other slave interfaces */ 107 + union { 108 + __u8 bSlaveInterface0; 109 + __DECLARE_FLEX_ARRAY(__u8, bSlaveInterfaces); 110 + }; 109 111 } __attribute__ ((packed)); 110 112 111 113 /* "Country Selection Functional Descriptor" from CDC spec 5.2.3.9 */ ··· 117 115 __u8 bDescriptorSubType; 118 116 119 117 __u8 iCountryCodeRelDate; 120 - __le16 wCountyCode0; 121 - /* ... and there can be a lot of country codes */ 118 + union { 119 + __le16 wCountryCode0; 120 + __DECLARE_FLEX_ARRAY(__le16, wCountryCodes); 121 + }; 122 122 } __attribute__ ((packed)); 123 123 124 124 /* "Network Channel Terminal Functional Descriptor" from CDC spec 5.2.3.11 */