Skip to content

Commit 1c2e54f

Browse files
Udipto Goswamigregkh
authored andcommitted
usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset()
For userspace functions using OS Descriptors, if a function also supplies Extended Property descriptors currently the counts and lengths stored in the ms_os_descs_ext_prop_{count,name_len,data_len} variables are not getting reset to 0 during an unbind or when the epfiles are closed. If the same function is re-bound and the descriptors are re-written, this results in those count/length variables to monotonically increase causing the VLA allocation in _ffs_func_bind() to grow larger and larger at each bind/unbind cycle and eventually fail to allocate. Fix this by clearing the ms_os_descs_ext_prop count & lengths to 0 in ffs_data_reset(). Fixes: f0175ab ("usb: gadget: f_fs: OS descriptors support") Cc: [email protected] Signed-off-by: Udipto Goswami <[email protected]> Signed-off-by: Sriharsha Allenki <[email protected]> Reviewed-by: Manu Gautam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a4e7279 commit 1c2e54f

File tree

1 file changed

+4
-0
lines changed
  • drivers/usb/gadget/function

1 file changed

+4
-0
lines changed

drivers/usb/gadget/function/f_fs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,6 +1813,10 @@ static void ffs_data_reset(struct ffs_data *ffs)
18131813
ffs->state = FFS_READ_DESCRIPTORS;
18141814
ffs->setup_state = FFS_NO_SETUP;
18151815
ffs->flags = 0;
1816+
1817+
ffs->ms_os_descs_ext_prop_count = 0;
1818+
ffs->ms_os_descs_ext_prop_name_len = 0;
1819+
ffs->ms_os_descs_ext_prop_data_len = 0;
18161820
}
18171821

18181822

0 commit comments

Comments
 (0)