Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp672778img; Fri, 22 Mar 2019 06:19:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8N2N3bm+5ZTFIOXFWPzBL6WzK5YDDR1b5X9IAoXFyQzlehrNHcqotzD84x2swz/xeFSzG X-Received: by 2002:a62:4754:: with SMTP id u81mr9308481pfa.66.1553260775571; Fri, 22 Mar 2019 06:19:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553260775; cv=none; d=google.com; s=arc-20160816; b=P3zv709K35QlWMXOPlmNIx+FXUEBtJym4OClPosvTx1LsZWKCSAfaBsW/kCXJ/IKGs MLanmplzzsO7hMzk2kmuJT2n8S2QnWTeI+Ll11i1H6d9NSOv7ATn9eBvNF/np8s+/rpa 6NMZmU5wH+44GsskOoHMgmDW6PS2Dtl+WpF/X1xnOWurFReCFo5Ff/OHzbh+N60Wx4r1 OVq0HqfKF/kZJksqPtzavBfdrwI5iHQVqZNnnrF3xvI/DeufCuH97Out6Nz/LR0xwSf8 DwwsrAoQbiA2B7bDi7c9YM7hgC9dV0ob3yyLAtOer/WcgCCVxj8gddSnCxtAXP9MEt6z zh3Q== 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=8VqLz1/1v+JlfXSeQ2XIR7VfN/HoWdhzM5uS6C4HgfE=; b=D5pOiWdqc5MgsPtVaHkH9A0GNTzTplc86ssfrLyZwF32PRwx3pE9DZDVSftn0euNH2 vQoMiuqPUIGsCz7y4fiFtntfmM3/FuIAp+7xAa8cc5ZuWzB4XK9sbKeT2CSo3VRGU4EW 4tpsgWAmhEd4UQu4p/QtlJ83itYstskwWV/Ns8OwEV9IMOWTTM3eb5wSX0iC6EIc49pA pDZzfpgIcPBpcaJIKG7oQC/7g6AecNTKu6wkM7eFE2uL8UlIEk7dslpd3MjW6GxZZRMo ffToW05CRi1cthGtBj8advXDhaoQn3ajFQXxXphogOUAFau9xlxmckB0Ygi9aQbELOtK uCxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MG5HdaOq; 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 x20si6885472plr.16.2019.03.22.06.19.17; Fri, 22 Mar 2019 06:19:35 -0700 (PDT) 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=MG5HdaOq; 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 S1728995AbfCVLXh (ORCPT + 99 others); Fri, 22 Mar 2019 07:23:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:50584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728375AbfCVLXf (ORCPT ); Fri, 22 Mar 2019 07:23:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 A4F4F218A2; Fri, 22 Mar 2019 11:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253815; bh=XDhqWP88MH6PuPJ8I5ZEfcn+Fwpi7muDGJeSRyzdXQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MG5HdaOqXQe3hseXPbMzgoZWEABs1tIHI5Ijnp6DhlPAd17XRJW9PhJPrYrteN8Uo J9axneSsZoXJjCwqAs+8X42n8WvdNjT65x1n88AcWUneWyT8IEFr2hQOpxTqCPVAnN e0tB3adlVspvZ+H0q/NIKMY2Etj6+e+MxnvBMQ1U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomonori Sakita , Atsushi Nemoto , Dalon L Westergreen , Thor Thayer , "David S. Miller" , Sasha Levin Subject: [PATCH 3.18 063/134] net: altera_tse: fix msgdma_tx_completion on non-zero fill_level case Date: Fri, 22 Mar 2019 12:14:36 +0100 Message-Id: <20190322111214.596798602@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 6571ebce112a21ec9be68ef2f53b96fcd41fd81b ] If fill_level was not zero and status was not BUSY, result of "tx_prod - tx_cons - inuse" might be zero. Subtracting 1 unconditionally results invalid negative return value on this case. Make sure not to return an negative value. Signed-off-by: Tomonori Sakita Signed-off-by: Atsushi Nemoto Reviewed-by: Dalon L Westergreen Acked-by: Thor Thayer Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/altera/altera_msgdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/altera/altera_msgdma.c b/drivers/net/ethernet/altera/altera_msgdma.c index 0fb986ba3290..0ae723f75341 100644 --- a/drivers/net/ethernet/altera/altera_msgdma.c +++ b/drivers/net/ethernet/altera/altera_msgdma.c @@ -145,7 +145,8 @@ u32 msgdma_tx_completions(struct altera_tse_private *priv) & 0xffff; if (inuse) { /* Tx FIFO is not empty */ - ready = priv->tx_prod - priv->tx_cons - inuse - 1; + ready = max_t(int, + priv->tx_prod - priv->tx_cons - inuse - 1, 0); } else { /* Check for buffered last packet */ status = csrrd32(priv->tx_dma_csr, msgdma_csroffs(status)); -- 2.19.1