aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUdipto Goswami <ugoswami@codeaurora.org>2020-04-02 10:15:21 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-04-29 16:31:34 +0200
commitb0a0ebfed4b2b218f7b1d357fba8a0942c14b333 (patch)
tree2c5a7404ac618ed17cf0b86adc07de0e74390e93
parentdbee0a82061a9d1623dea35c34bc79c5e9b7daa1 (diff)
downloadlinux-yocto-b0a0ebfed4b2b218f7b1d357fba8a0942c14b333.tar.gz
linux-yocto-b0a0ebfed4b2b218f7b1d357fba8a0942c14b333.tar.bz2
linux-yocto-b0a0ebfed4b2b218f7b1d357fba8a0942c14b333.zip
usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset()
commit 1c2e54fbf1da5e5445a0ab132c862b02ccd8d230 upstream. 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: f0175ab51993 ("usb: gadget: f_fs: OS descriptors support") Cc: stable@vger.kernel.org Signed-off-by: Udipto Goswami <ugoswami@codeaurora.org> Signed-off-by: Sriharsha Allenki <sallenki@codeaurora.org> Reviewed-by: Manu Gautam <mgautam@codeaurora.org> Link: https://lore.kernel.org/r/20200402044521.9312-1-sallenki@codeaurora.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/gadget/function/f_fs.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 31b3dda3089c..11a501d0664c 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1737,6 +1737,10 @@ static void ffs_data_reset(struct ffs_data *ffs)
ffs->state = FFS_READ_DESCRIPTORS;
ffs->setup_state = FFS_NO_SETUP;
ffs->flags = 0;
+
+ ffs->ms_os_descs_ext_prop_count = 0;
+ ffs->ms_os_descs_ext_prop_name_len = 0;
+ ffs->ms_os_descs_ext_prop_data_len = 0;
}