]> git.baikalelectronics.ru Git - kernel.git/commit
usb: gadget: f_fs: Use config_ep_by_speed()
authorJack Pham <jackp@codeaurora.org>
Thu, 25 Jan 2018 07:58:20 +0000 (23:58 -0800)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 12 Feb 2018 08:52:54 +0000 (10:52 +0200)
commitb1d0aa6b45eac83fdf08d1560694b8453ca683e0
tree319e0dd41ec839dfe0dcc4185879060e6f9287d7
parent2b13bb48ebdf7f1a26e26974f2959528a8f93a47
usb: gadget: f_fs: Use config_ep_by_speed()

In commit 0cc9fefc5847 ("usb: gadget: function: f_fs: pass
companion descriptor along") there is a pointer arithmetic
bug where the comp_desc is obtained as follows:

 comp_desc = (struct usb_ss_ep_comp_descriptor *)(ds +
       USB_DT_ENDPOINT_SIZE);

Since ds is a pointer to usb_endpoint_descriptor, adding
7 to it ends up going out of bounds (7 * sizeof(struct
usb_endpoint_descriptor), which is actually 7*9 bytes) past
the SS descriptor. As a result the maxburst value will be
read incorrectly, and the UDC driver will also get a garbage
comp_desc (assuming it uses it).

Since Felipe wrote, "Eventually, f_fs.c should be converted
to use config_ep_by_speed() like all other functions, though",
let's finally do it. This allows the other usb_ep fields to
be properly populated, such as maxpacket and mult. It also
eliminates the awkward speed-based descriptor lookup since
config_ep_by_speed() does that already using the ones found
in struct usb_function.

Fixes: 0cc9fefc5847 ("usb: gadget: function: f_fs: pass companion descriptor along")
Cc: stable@vger.kernel.org
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/function/f_fs.c