Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2528136imu; Thu, 29 Nov 2018 06:26:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/VdcLSnFROUeyFqc9BysTi33xDSRIEuw0hSjzUKvp+4AfHaZubjqOLnq/xdg6wit0l+T/jo X-Received: by 2002:aa7:81d0:: with SMTP id c16mr1567040pfn.153.1543501611179; Thu, 29 Nov 2018 06:26:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501611; cv=none; d=google.com; s=arc-20160816; b=qa+H2O1ZUwfEJCWyDF8t0jBUM0PUoDohA71bq04CSqH0/hbsvaxr6uG40Tv8RUeRI/ qAr6Aj/QqWjLYrIwu7y3VW+gTuMqVTNZxCzW4Nhq7+x9+KE2u3l82qoTb54m92jKPeIR OWXIG3h6irZUFZB4nyy8m5mT8Zri7F3fyJAVN/wccgCqiRh5usRzTj4BCuIrA8EAbgqL PLUUCm1B8qcPIjVfAz7DNMwU7El3z8bo81hq0TBb98UhAe8blqLnlvKXlIS34MA0sqNK Pyg5DjIiahwjD/r+Uv99cNEqwP5Knjb+5aPZlbQ4fIB0ATCSsjJ4GD9NEu3Wz8e3Rm3G 3i5w== 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=xt9PCH+y/TOa0mPKBFJFXEWx4YvCGB2T6umPDf0yeps=; b=oh2aK0UhNbYUAOs3QNm+APRMfjk++7+ZO/2FSX8GdUZFrJKxj3U9vV9eSGJaDydikN OiHjasvR1jb3O+hmxFLxeco7mAfEIJAwO4fx5S7lPLJs+3odwI4mB88yTatmmQL83NoR qEuVRTChLzrbn039DEWhbBTJfBS4ODHNy8+X8bEIiorB7NIU2201w1rr4Tu/F73EQW1t 6EqEjkBaHV7SukRWdjQSJ0Dq13kfPgf0G9x3NI5kmmcZNxAamvxHr7Q6EOcZF6s0pvCs 9j7TJRPWF55YE9N4j/cOykTHiVlae/gG/Hdx/fe9whbqlmAFYkCRVn7F7LvunPgLdmmF RDAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kqI8fxyP; 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 s73si2161258pfs.54.2018.11.29.06.26.36; Thu, 29 Nov 2018 06:26:51 -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=kqI8fxyP; 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 S1732734AbeK3BaP (ORCPT + 99 others); Thu, 29 Nov 2018 20:30:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:57146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732729AbeK3BaO (ORCPT ); Thu, 29 Nov 2018 20:30:14 -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 C2F5B205C9; Thu, 29 Nov 2018 14:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501482; bh=ytVCJhGjiwGEid38vrm4PcEGUz1X8CgOYwRI5Fa4rW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kqI8fxyPIRlK4vbpZ2AjfjahpdcEqYQJTFyyvzifONzKlDugpTNy8KKQyogU2eybm 25BLQc/3ScsATzVE46Lrt4uOYbJISiakvE70PrYleaizGBneCUAswnBFvDnFfRVNZa P6601Ba/c8yp0AEA514DW7/6TyQ/O8J9QAi8DnAs= 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.14 008/100] usb: dwc3: gadget: Properly check last unaligned/zero chain TRB Date: Thu, 29 Nov 2018 15:11:38 +0100 Message-Id: <20181129140059.633303880@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140058.768942700@linuxfoundation.org> References: <20181129140058.768942700@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.14-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 @@ -2249,7 +2249,7 @@ static int __dwc3_cleanup_done_trbs(stru * 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; }