]> www.infradead.org Git - users/dwmw2/linux.git/commit
usb: gadget: f_fs: set req->num_sgs as 0 for non-sg transfer
authorPeter Chen <peter.chen@nxp.com>
Thu, 12 Dec 2019 08:35:03 +0000 (16:35 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2020 12:36:41 +0000 (04:36 -0800)
commiteeac0324bc9b45776c28be2f7b4e8c264b2f2c86
tree61e49281766b43b60c045c4362decde695c54beb
parentc9948008472b32e0deddec421499e05fce7dd994
usb: gadget: f_fs: set req->num_sgs as 0 for non-sg transfer

commit d2450c6937018d40d4111fe830fa48d4ddceb8d0 upstream.

The UDC core uses req->num_sgs to judge if scatter buffer list is used.
Eg: usb_gadget_map_request_by_dev. For f_fs sync io mode, the request
is re-used for each request, so if the 1st request->length > PAGE_SIZE,
and the 2nd request->length is <= PAGE_SIZE, the f_fs uses the 1st
req->num_sgs for the 2nd request, it causes the UDC core get the wrong
req->num_sgs value (The 2nd request doesn't use sg). For f_fs async
io mode, it is not harm to initialize req->num_sgs as 0 either, in case,
the UDC driver doesn't zeroed request structure.

Cc: Jun Li <jun.li@nxp.com>
Cc: stable <stable@vger.kernel.org>
Fixes: 772a7a724f69 ("usb: gadget: f_fs: Allow scatter-gather buffers")
Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_fs.c