Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2546255imu; Thu, 29 Nov 2018 06:41:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/WX/yapbqScXChAvYBueAL0IpEt4BJf5IU694SXlT+Dub97dy9wtUFwinH17G0TXlr9FnTA X-Received: by 2002:a63:da14:: with SMTP id c20mr1384655pgh.233.1543502515237; Thu, 29 Nov 2018 06:41:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543502515; cv=none; d=google.com; s=arc-20160816; b=aRXYSaIIijpN9cDk+lSHYqYD23Mm7ex5vkDDJ11DCeYurf83BNWp5pNkxUV2US1gv7 fFr1az4toCS7Euq1t0sWvRpUKcuIqzFosAaMIKEkvJgZVeEParZUW02/Mg0odeJHOeTp K06+yBGRr1boWnIowhCMWkCuR3jHETyCGwNudjaHHNglMd7dNV/Omu2Ix84cBTM7VrrE zpyrOZi+Xrf7zX6bDI8JKajY301/JuX6eh3Os6Hb546nHuJ3diQGzYE+xdIBsOuVpnvw hyUz84VmmsIEI/a1PENmS1WCjdquWDy1zxehV6RwDTcug/IFtB6hddCCqjtkuhg8hGn/ zjMg== 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=TbfpHCvG7L70dNvUptfM09q7MqUUiULk9qTr1s7bICE=; b=N8VC8Vq016mFrzplP+nVxtqHCWOjTkq6Re0AI+wUsxS1wmBAapWQz555VDHBZ4YAn5 +9ucg5JcOzwOM4Ym1kr/ooEv8VpBbKU/DHyBHLrCvd2tcOWSXRmF0qCjJpTCWVTE9Bhc E906kFn8i22BZRhX+CqSQzho6uNFv4WaItD18sBmcAYtJdsv7YyrzDGStQaQVtu9v0yC zPusQrwHFfLHBmwi+0cKjYqd7OzXbCvc+Ifc7zouF7obSGxzGn1EvY1Nu3RxmdatQMzm x8xf7NduuszDjPTf/ab2OIpsSlMqMfw9FTNc2SqSU6FRyvGp/y70YVmVeSLjDVXFPsu6 kWpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Bwpn9+Gr; 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 cd16si2619822plb.47.2018.11.29.06.41.32; Thu, 29 Nov 2018 06:41:55 -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=Bwpn9+Gr; 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 S2388237AbeK3Be3 (ORCPT + 99 others); Thu, 29 Nov 2018 20:34:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:35680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731986AbeK3Be2 (ORCPT ); Thu, 29 Nov 2018 20:34:28 -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 ABF15213A2; Thu, 29 Nov 2018 14:28:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501736; bh=148Ocxf2G37iWIY4WCvt/2J980GP5faPL6L1wY2sDBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bwpn9+GrzfMcbqky3SsMjpKa16I+1QrJAlhcjci0rOCqzJiR3959Y/aDen8HGfVdA rUtkyBiJMCkAcycMkJuTQiQT0jSlxBC11OYqzKFVm1i5qfnEBycuraLQJ6DX2pn/nr OZy/loAkxoFD9rtqNR0fDpPGcRaeZLEuIB1fNXPg= 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 005/110] usb: dwc3: gadget: Properly check last unaligned/zero chain TRB Date: Thu, 29 Nov 2018 15:11:36 +0100 Message-Id: <20181129135921.457321726@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129135921.231283053@linuxfoundation.org> References: <20181129135921.231283053@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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: Thinh Nguyen commit ba3a51ac32ebcf8d0a54b37f1af268ad8a31c52f upstream. Current check for the last extra TRB for zero and unaligned transfers does not account for isoc OUT. The last TRB of the Buffer Descriptor for isoc OUT transfers will be retired with HWO=0. As a result, we won't return early. The req->remaining will be updated to include the BUFSIZ count of the extra TRB, and the actual number of transferred bytes calculation will be wrong. To fix this, check whether it's a short or zero packet and the last TRB chain bit to return early. Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize") Cc: Signed-off-by: Thinh Nguyen Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2250,7 +2250,7 @@ static int dwc3_gadget_ep_reclaim_comple * with one TRB pending in the ring. We need to manually clear HWO bit * from that TRB. */ - if ((req->zero || req->unaligned) && (trb->ctrl & DWC3_TRB_CTRL_HWO)) { + if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) { trb->ctrl &= ~DWC3_TRB_CTRL_HWO; return 1; }