aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Neukum <oneukum@suse.com>2025-11-11 14:46:10 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-11-21 15:12:12 +0100
commita67df6d1b939ca98e1ad403f53e3ee57299b8c44 (patch)
tree240973fd9aa297d11036e368cfc5875d01ea8bbe
parent8d3c283ef80950532500f017a80a00a83e8cce0f (diff)
downloadtip-a67df6d1b939ca98e1ad403f53e3ee57299b8c44.tar.gz
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>
-rw-r--r--drivers/usb/class/cdc-acm.c2
-rw-r--r--include/uapi/linux/usb/cdc.h12
2 files changed, 9 insertions, 5 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 73f9476774ae6a..54be4aa1dcb2af 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1475,7 +1475,7 @@ made_compressed_probe:
if (!acm->country_codes)
goto skip_countries;
acm->country_code_size = cfd->bLength - 4;
- memcpy(acm->country_codes, (u8 *)&cfd->wCountyCode0,
+ memcpy(acm->country_codes, cfd->wCountryCodes,
cfd->bLength - 4);
acm->country_rel_date = cfd->iCountryCodeRelDate;
diff --git a/include/uapi/linux/usb/cdc.h b/include/uapi/linux/usb/cdc.h
index 1924cf665448d0..7bd5d12d8b26c9 100644
--- a/include/uapi/linux/usb/cdc.h
+++ b/include/uapi/linux/usb/cdc.h
@@ -104,8 +104,10 @@ struct usb_cdc_union_desc {
__u8 bDescriptorSubType;
__u8 bMasterInterface0;
- __u8 bSlaveInterface0;
- /* ... and there could be other slave interfaces */
+ union {
+ __u8 bSlaveInterface0;
+ __DECLARE_FLEX_ARRAY(__u8, bSlaveInterfaces);
+ };
} __attribute__ ((packed));
/* "Country Selection Functional Descriptor" from CDC spec 5.2.3.9 */
@@ -115,8 +117,10 @@ struct usb_cdc_country_functional_desc {
__u8 bDescriptorSubType;
__u8 iCountryCodeRelDate;
- __le16 wCountyCode0;
- /* ... and there can be a lot of country codes */
+ union {
+ __le16 wCountryCode0;
+ __DECLARE_FLEX_ARRAY(__le16, wCountryCodes);
+ };
} __attribute__ ((packed));
/* "Network Channel Terminal Functional Descriptor" from CDC spec 5.2.3.11 */