Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4489462ivc; Tue, 3 Nov 2020 13:24:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/yehKfEI/VIelPG18DRgDAyMaST5iMG4pn+pei3S35DJBoXhgF+iDF4zkkqEo2GlBUIoD X-Received: by 2002:a17:907:2110:: with SMTP id qn16mr22674477ejb.133.1604438649980; Tue, 03 Nov 2020 13:24:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604438649; cv=none; d=google.com; s=arc-20160816; b=ba1iIoHt69BvISB2Rev8z+lLmlY2YlEcfz6c5pL2s8KtB+eIb//zrZ1reH+9d7Rleu G+vKnC6yzb9apU+/r6IIpKP6isSZD/cPVXFCAG33JAMf/gwJbDb6Y5O/osul2TQMgaZM 2i7TIdCfkkrejS0Loy79u2i5ESCAcyObdNXVdYgLerVU00Hi5eqRv9EJXQTzifDKySAC c6RYmEnsdlnGZGGSWl/tNC8pBHFNsM/ynIYJcFGPyTgBeSXAUKlAvQ3qTY4Xty5IXv0I TtuQbigDlrIE8ZPz0ViiGcB5VBZ5fMpbqlDyJPW4d1/yCppsT7lJz4AEe2C1m79Mud1b YKrA== 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=z2T0K8Szjel1+K3isewXbWEUfolIXvL1m2qo98jbjUc18EU2SnRvUE5CmgwLSYnHn7 +XGA38oSjunS874LK+ofQy6pMGgr7RcioHdm6oQIU1/PyVwcANa8xj7EMsiQ80xoXUvD 5nCgexzYvlc8nbdd5brqgRrjHSZU3ykO4ynvQ1LjKGZ0F30iiOAaoSpvOyb4WVj/sHD9 WMnQZhwhFFIHzk1yEGyusDONjrszeaXgdCy44gzhR0Ao1HqnjGsfD2s1FTcUtcE31t9q cBFiGh5fHA6xAOX5Aw9/MC+xdHSYHCLooWRuoE0Tm76z1uEFr8uIoPT8NalsKlnZRXCc 8ZLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=swC262dp; 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 x7si6723983edr.509.2020.11.03.13.23.46; Tue, 03 Nov 2020 13:24:09 -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=swC262dp; 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 S2388407AbgKCVVR (ORCPT + 99 others); Tue, 3 Nov 2020 16:21:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:45178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388133AbgKCVGS (ORCPT ); Tue, 3 Nov 2020 16:06:18 -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 52D8D205ED; Tue, 3 Nov 2020 21:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437577; bh=71ZehZ3+PO2T+WEyXk27DSKW9Y8mJr4AEfNFxJE53Ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=swC262dpjusNrfSRPN3cIjo7KLfA2/OxlXysdmhuUSUzKnFEvBEXN3J1dyhFnK0L8 57Vn5krejf0ALnAcUwPepChuHSbFYhK2YNi9hZbjpyb5apcWlaG3sgK6aEbyyeeFmO wiZkcNNrfxUKlP9XJDTvEkIJB5NryG73jFPsIH3E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thinh Nguyen , Felipe Balbi Subject: [PATCH 4.19 137/191] usb: dwc3: gadget: Check MPS of the request length Date: Tue, 3 Nov 2020 21:37:09 +0100 Message-Id: <20201103203245.789221376@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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;