usb: dwc2: Do not update data length if it is 0 on inbound transfers
authorGuenter Roeck <linux@roeck-us.net>
Wed, 13 Jan 2021 11:20:49 +0000 (12:20 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Mar 2021 16:44:33 +0000 (17:44 +0100)
commit5497b8060f04f0750d54b01fdff6731a3ed05d6f
tree73ce9ecd0a3d7262b2e1afd581e2f411d43402e1
parenta17c47fc75aa7c7e0ccda4e4c73b6735e753ca4f
usb: dwc2: Do not update data length if it is 0 on inbound transfers

[ Upstream commit 415fa1c7305dedbb345e2cc8ac91769bc1c83f1a ]

The DWC2 documentation states that transfers with zero data length should
set the number of packets to 1 and the transfer length to 0. This is not
currently the case for inbound transfers: the transfer length is set to
the maximum packet length. This can have adverse effects if the chip
actually does transfer data as it is programmed to do. Follow chip
documentation and keep the transfer length set to 0 in that situation.

Fixes: 56f5b1cff22a1 ("staging: Core files for the DWC2 driver")
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Link: https://lore.kernel.org/r/20210113112052.17063-2-nsaenzjulienne@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/dwc2/hcd.c