]> git.ipfire.org Git - people/arne_f/kernel.git/commit
usb: gadget: f_fs: Process all descriptors during bind
authorJack Pham <jackp@codeaurora.org>
Wed, 24 Jan 2018 08:11:53 +0000 (00:11 -0800)
committerSasha Levin <alexander.levin@microsoft.com>
Sun, 4 Mar 2018 15:28:34 +0000 (10:28 -0500)
commitb177a6a134847538b78c12fffb49afe2f8335be0
treef69bb87ef300726bd173eba2f8694ac10d013da4
parent65238bd966d75fd7b65f9dd21291f75251390286
usb: gadget: f_fs: Process all descriptors during bind

[ Upstream commit 6cf439e0d37463e42784271179c8a308fd7493c6 ]

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: Sasha Levin <alexander.levin@microsoft.com>
drivers/usb/gadget/function/f_fs.c