usb: gadget: f_fs: Accept up to 30 endpoints.
authorVincent Pelletier <plr.vincent@gmail.com>
Mon, 23 Jan 2017 14:41:04 +0000 (14:41 +0000)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 24 Jan 2017 09:04:23 +0000 (11:04 +0200)
It is allowed by the USB specification to enabled same-address, opposite-
direction endpoints simultaneously, which means 30 non-zero endpoints
are allowed. So double eps_addrmap length to 30.
The original code only accepted 14 descriptors out of a likely intended 15
(as there are 15 endpoint addresses, ignoring direction), because the first
eps_addrmap entry is unused (it is a placeholder for endpoint zero). So
increase eps_addrmap length by one to 31.

Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/function/f_fs.c
drivers/usb/gadget/function/u_fs.h

index e126897a7faedcf7bf247f7e9714867b26cf3ddf..f5d6bf527aac6f445a412a38b284d2301f127951 100644 (file)
@@ -2101,7 +2101,7 @@ static int __ffs_data_do_entity(enum ffs_entity_type type,
        case FFS_ENDPOINT:
                d = (void *)desc;
                helper->eps_count++;
-               if (helper->eps_count >= 15)
+               if (helper->eps_count >= FFS_MAX_EPS_COUNT)
                        return -EINVAL;
                /* Check if descriptors for any speed were already parsed */
                if (!helper->ffs->eps_count && !helper->ffs->interfaces_count)
index 60139854e0b1b320d66f15b5b1f0d954e72e634d..4b6969451cdc28dcfabb4db8806a403df1199e0d 100644 (file)
@@ -247,7 +247,8 @@ struct ffs_data {
 
        unsigned                        user_flags;
 
-       u8                              eps_addrmap[15];
+#define FFS_MAX_EPS_COUNT 31
+       u8                              eps_addrmap[FFS_MAX_EPS_COUNT];
 
        unsigned short                  strings_count;
        unsigned short                  interfaces_count;