Skip to content

Commit a67df6d

Browse files
oneukumgregkh
authored andcommitted
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>
1 parent 8d3c283 commit a67df6d

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/usb/class/cdc-acm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ static int acm_probe(struct usb_interface *intf,
14751475
if (!acm->country_codes)
14761476
goto skip_countries;
14771477
acm->country_code_size = cfd->bLength - 4;
1478-
memcpy(acm->country_codes, (u8 *)&cfd->wCountyCode0,
1478+
memcpy(acm->country_codes, cfd->wCountryCodes,
14791479
cfd->bLength - 4);
14801480
acm->country_rel_date = cfd->iCountryCodeRelDate;
14811481

include/uapi/linux/usb/cdc.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ struct usb_cdc_union_desc {
104104
__u8 bDescriptorSubType;
105105

106106
__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+
};
109111
} __attribute__ ((packed));
110112

111113
/* "Country Selection Functional Descriptor" from CDC spec 5.2.3.9 */
@@ -115,8 +117,10 @@ struct usb_cdc_country_functional_desc {
115117
__u8 bDescriptorSubType;
116118

117119
__u8 iCountryCodeRelDate;
118-
__le16 wCountyCode0;
119-
/* ... and there can be a lot of country codes */
120+
union {
121+
__le16 wCountryCode0;
122+
__DECLARE_FLEX_ARRAY(__le16, wCountryCodes);
123+
};
120124
} __attribute__ ((packed));
121125

122126
/* "Network Channel Terminal Functional Descriptor" from CDC spec 5.2.3.11 */

0 commit comments

Comments
 (0)