]> git.baikalelectronics.ru Git - kernel.git/commit
usb: f_fs: Clear OS Extended descriptor counts to zero in ffs_data_reset()
authorUdipto Goswami <ugoswami@codeaurora.org>
Thu, 2 Apr 2020 04:45:21 +0000 (10:15 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Apr 2020 12:59:49 +0000 (14:59 +0200)
commit00d6b8a75217c6c276e39433bedcf33b9a431156
tree8769dc24ade2e5b8a736527c4f9c16520219636d
parent88aadc9773ff74b7fe07ce90fff460f3dcb16c4a
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: b4e77928b3f5 ("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>
drivers/usb/gadget/function/f_fs.c