Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4568906imu; Tue, 29 Jan 2019 03:59:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN6XzdYKjhrNtK4oE/VgiA1xjBfqCjyhFH7PjvHzBIu31F6OCFDR/zv0c1kdw694zVLinlD7 X-Received: by 2002:a17:902:f64:: with SMTP id 91mr25633436ply.132.1548763178916; Tue, 29 Jan 2019 03:59:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548763178; cv=none; d=google.com; s=arc-20160816; b=VotvrN3LxS+d45BWnKXOq0wXelerKfj6wl6u4QTcvQccAIcWHk4/hPL0DN8wJ2vsTD wq/PD2DoCXm9NGCWzHyuO/uuBzxB+UwPpmqImfLvXp5tw70kDZeHiVYtyJmA9/9gW9VE LwK7RFgkq64A5UeqSFlRu4VaHFdyfgnAyp8ZfYKvm3QmlHQMsrEB9Z7Fb9MY4AseYgqT Zo1GANlLhmUeYtkeOIt63aJH0nDpxu6tUC5wi8y4rCWwM2CYXVqrseN2Fxrw5oF9TxD8 uwgBT6cVQzCGbiKreaSYPhI5g4wnZRgCpnaxiL0ve/4l355+rGsImka0YImUivKhek/g xzVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TwV4egvkHS1N8afHWMesb7R9AV2MEmo29mHDMeUQPmY=; b=kFbvHHVQotdyKRqtmdsdcOmlxA9hXhSn1rzJ+BryCCg4YXaASHvNLME5kNofz6P2qh PbWSWEIoz8Vm3g8sxrzeyq1FllOo7IWrZLi5zaylVCeCqthCTfkGvj3hQhD0LAzc78Wy XS8UnCxhj0z2YsivRLztuElnFF+sI05vOV5ttkOwvXDrmvBzOF4wsWJMbQnDsQ4u79VW RPL//hdx94ezVMkIl+AKCW2MSUKFZIiOtjXyJUswgqmo74u9uohasfErlxKIQNu/rUl7 NZQxyFySzdcE/XJ821DllXaCB0T4Wx77H5AzKqSYUuHAEF3QRFiL1QcKdUlLvx8x/3Tz KNGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KTNeVWOn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a6si35660190pfo.90.2019.01.29.03.59.23; Tue, 29 Jan 2019 03:59:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KTNeVWOn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731447AbfA2L7N (ORCPT + 99 others); Tue, 29 Jan 2019 06:59:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:38016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731179AbfA2LrV (ORCPT ); Tue, 29 Jan 2019 06:47:21 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 C76D32086C; Tue, 29 Jan 2019 11:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548762441; bh=Y2kuHpNnFiSHYlV1fU4otSpAWOOwpdFCLWJhvjrcAYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KTNeVWOncpM4kUJBc4EZ5ECcC1kRfh8SdMtxrfdQWi1xgi0Wb00uW0QtmDAsw3NOa CeILwvocc2aw3KfXtITeQPkQjsJLFJBfV9Krr5lJbQGzsxVSiFWrEO94fE0bZEjtnF oxsmsDyszAlv3ZdF+VUUP2Kdb5XYCG4vui+EIdSc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Pham , Felipe Balbi Subject: [PATCH 4.19 102/103] usb: dwc3: gadget: Clear req->needs_extra_trb flag on cleanup Date: Tue, 29 Jan 2019 12:36:19 +0100 Message-Id: <20190129113207.610918252@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129113159.567154026@linuxfoundation.org> References: <20190129113159.567154026@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jack Pham commit bd6742249b9ca918565e4e3abaa06665e587f4b5 upstream. OUT endpoint requests may somtimes have this flag set when preparing to be submitted to HW indicating that there is an additional TRB chained to the request for alignment purposes. If that request is removed before the controller can execute the transfer (e.g. ep_dequeue/ep_disable), the request will not go through the dwc3_gadget_ep_cleanup_completed_request() handler and will not have its needs_extra_trb flag cleared when dwc3_gadget_giveback() is called. This same request could be later requeued for a new transfer that does not require an extra TRB and if it is successfully completed, the cleanup and TRB reclamation will incorrectly process the additional TRB which belongs to the next request, and incorrectly advances the TRB dequeue pointer, thereby messing up calculation of the next requeust's actual/remaining count when it completes. The right thing to do here is to ensure that the flag is cleared before it is given back to the function driver. A good place to do that is in dwc3_gadget_del_and_unmap_request(). Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize") Cc: stable@vger.kernel.org Signed-off-by: Jack Pham Signed-off-by: Felipe Balbi [jackp: backport to <= 4.20: replaced 'needs_extra_trb' with 'unaligned' and 'zero' members in patch and reworded commit text] Signed-off-by: Jack Pham Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/gadget.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -177,6 +177,8 @@ static void dwc3_gadget_del_and_unmap_re req->started = false; list_del(&req->list); req->remaining = 0; + req->unaligned = false; + req->zero = false; if (req->request.status == -EINPROGRESS) req->request.status = status;