Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp823162pxb; Tue, 3 Nov 2020 13:33:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0OvgDKVXyQCQ5b1K1Zr1kNlBgXz/PyQ+TSduqek1BIPPXhuSGrTlOEn+4SrKZsclG0Ote X-Received: by 2002:a17:906:5a97:: with SMTP id l23mr4494239ejq.232.1604439211154; Tue, 03 Nov 2020 13:33:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439211; cv=none; d=google.com; s=arc-20160816; b=f+5ueBiU4inxRaT0cZrHGjcDwd9KtyEjti90pq/dT06VQ3so7F8pCPehtKp/pGuu7M 0AeAPJTybbhNaXvd/qvHzkO85hkOpJSKD+2UW6RsW93q8riY8GJdl0n+NyHXK5U3Zzk8 F+5xlfA9Jqik2GyVs0KFpk4WhMugPJn6QZ0SE6yiGJ7MV7hSs8treGOCw/CbqvYt66GD e7z20P71rdkTrl3rh8JkxAgVnlSFjCQfTg8a6VWYMuhHHWgdSbBzvlmnXLPTR/GsrdJb PTPh8kaCnF4mhsBaFLTdlhwe8c2FfNIY/gvOUiaBHbFsshGhws19lHy7j+8i60Li2JvR oc+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4wZ2K3KiSkKpn70HX7qH61pn8XDsI+U85xtuAbV3JYE=; b=nhaBta3pLsZ0f1N4K85kONnN0cLxxn0AUoWGaGS3hH7ljujKQoaeEhtr6WXtst7nIO FQes+56OLXukN5M3Topj4vyVo7TFF2+u3BOCUQzzk0+x/fqlNAEHP0nEKlHsvO2Z24Xa 8D+UO2SFS2z2TEd4JeXAxnTwbzH8U+NkJN+gRcwd1kT0gf5J9te8yeNTA0aeyaXHBo0R tIuwo7jW1pYxraQ0pte5JsOen7Cl6BxyLjaoZqLEo8RPsxhK7KVlw7wHpMrAqW79Ir12 +MVYSArqi1nH9ImFqYe5BMT/0NIyDl8PZfB2Gyg47t4gX+ff7UmrSD2e4c/3BmaMK0KO /9iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AGvc9otg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r12si64032ejr.690.2020.11.03.13.33.07; Tue, 03 Nov 2020 13:33:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AGvc9otg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732534AbgKCVap (ORCPT + 99 others); Tue, 3 Nov 2020 16:30:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:60510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731057AbgKCU55 (ORCPT ); Tue, 3 Nov 2020 15:57:57 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 52A0B22226; Tue, 3 Nov 2020 20:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437076; bh=71ZehZ3+PO2T+WEyXk27DSKW9Y8mJr4AEfNFxJE53Ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AGvc9otgtd8sBVIBZjUykw1J5I0oIZhU/yroxTzqLL4KlOe2ObrtzzpFsNW7OlTVb KhnTBNIdWd2cLmqDvXEaqZhRBo0/mJRsZjezYmGcPAlGEwJtlDh0xa8f04BcTtj2Os HBIe7OT/OIpr3bAoyfqXL08HcWqOzd2Q/pxW7Fdw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thinh Nguyen , Felipe Balbi Subject: [PATCH 5.4 136/214] usb: dwc3: gadget: Check MPS of the request length Date: Tue, 3 Nov 2020 21:36:24 +0100 Message-Id: <20201103203303.582071131@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thinh Nguyen commit ca3df3468eec87f6374662f7de425bc44c3810c1 upstream. When preparing for SG, not all the entries are prepared at once. When resume, don't use the remaining request length to calculate for MPS alignment. Use the entire request->length to do that. Cc: stable@vger.kernel.org Fixes: 5d187c0454ef ("usb: dwc3: gadget: Don't setup more than requested") Signed-off-by: Thinh Nguyen Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/gadget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1057,6 +1057,8 @@ static void dwc3_prepare_one_trb_sg(stru struct scatterlist *s; int i; unsigned int length = req->request.length; + unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); + unsigned int rem = length % maxp; unsigned int remaining = req->request.num_mapped_sgs - req->num_queued_sgs; @@ -1068,8 +1070,6 @@ static void dwc3_prepare_one_trb_sg(stru length -= sg_dma_len(s); for_each_sg(sg, s, remaining, i) { - unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc); - unsigned int rem = length % maxp; unsigned int trb_length; unsigned chain = true;