In the dwc3_prepare_trbs_sg routine, when all data from request was handled pending_sgs should be set to the number of mapped sgs that are not queued up. Currently the code will result in pending_sgs == queued_sgs. That variables value will likely not be zero and break dwc3_prepare_trbs. This patch fixes the setting of the variable to its intended purpose. Signed-off-by: Michael Grzeschik <m.grzeschik@xxxxxxxxxxxxxx> --- drivers/usb/dwc3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 6227641f2d318..118b5bcc565d6 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1242,7 +1242,7 @@ static int dwc3_prepare_trbs_sg(struct dwc3_ep *dep, * don't include unused SG entries. */ if (length == 0) { - req->num_pending_sgs -= req->request.num_mapped_sgs - req->num_queued_sgs; + req->num_pending_sgs = req->request.num_mapped_sgs - req->num_queued_sgs; break; } -- 2.29.2