summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Pham <jackp@codeaurora.org>2018-01-24 00:11:53 -0800
committerDongwoo Lee <dwoo08.lee@samsung.com>2019-11-26 11:22:41 +0900
commitb71ef6da9e9906b6f6e37b98205f1409c461d3b4 (patch)
treeb9d43a7139e45123396f4370d95b917034a2bd80
parent8456de9c37805264becc5489af0f8c85a184adfa (diff)
downloadlinux-4.9-exynos9110-b71ef6da9e9906b6f6e37b98205f1409c461d3b4.tar.gz
linux-4.9-exynos9110-b71ef6da9e9906b6f6e37b98205f1409c461d3b4.tar.bz2
linux-4.9-exynos9110-b71ef6da9e9906b6f6e37b98205f1409c461d3b4.zip
usb: gadget: f_fs: Process all descriptors during bind
commit 6cf439e0d37463e42784271179c8a308fd7493c6 upstream. During _ffs_func_bind(), the received descriptors are evaluated to prepare for binding with the gadget in order to allocate endpoints and optionally set up OS descriptors. However, the high- and super-speed descriptors are only parsed based on whether the gadget_is_dualspeed() and gadget_is_superspeed() calls are true, respectively. This is a problem in case a userspace program always provides all of the {full,high,super,OS} descriptors when configuring a function. Then, for example if a gadget device is not capable of SuperSpeed, the call to ffs_do_descs() for the SS descriptors is skipped, resulting in an incorrect offset calculation for the vla_ptr when moving on to the OS descriptors that follow. This causes ffs_do_os_descs() to fail as it is now looking at the SS descriptors' offset within the raw_descs buffer instead. _ffs_func_bind() should evaluate the descriptors unconditionally, so remove the checks for gadget speed. Fixes: f0175ab51993 ("usb: gadget: f_fs: OS descriptors support") Cc: stable@vger.kernel.org Co-Developed-by: Mayank Rana <mrana@codeaurora.org> Signed-off-by: Mayank Rana <mrana@codeaurora.org> Signed-off-by: Jack Pham <jackp@codeaurora.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [dwoo08.lee: cherry-pick linux-4.9.y stable commit 8bedacf13d59 to stablize f_fs] Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com> Change-Id: I0ed8330a0e692ea80263f31b7804203edfbd2d4d
-rw-r--r--drivers/usb/gadget/function/f_fs.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 59ad9c34b0af..231e0379578d 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2967,10 +2967,8 @@ static int _ffs_func_bind(struct usb_configuration *c,
struct ffs_data *ffs = func->ffs;
const int full = !!func->ffs->fs_descs_count;
- const int high = gadget_is_dualspeed(func->gadget) &&
- func->ffs->hs_descs_count;
- const int super = gadget_is_superspeed(func->gadget) &&
- func->ffs->ss_descs_count;
+ const int high = !!func->ffs->hs_descs_count;
+ const int super = !!func->ffs->ss_descs_count;
int fs_len, hs_len, ss_len, ret, i;
struct ffs_ep *eps_ptr;