Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2231987ybi; Thu, 20 Jun 2019 11:17:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaD0pAeRIrjg9Wd3tc7wj940AXIe2NBjLn2MUvM3IcqGqOjYq3MhJw6v9GVg41fEP60NMN X-Received: by 2002:a17:902:9b81:: with SMTP id y1mr103861784plp.194.1561054622003; Thu, 20 Jun 2019 11:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561054621; cv=none; d=google.com; s=arc-20160816; b=UTtkzkYItjExNzSFgHCkH0jn3jTz7x4t4SKoXfVwJGentrNoc/SqeczdOEYLn76KEY cxGUmyZRS7xtrJ1w8pl0/6Lv3nEVxOVufkpAP+4odf/LMsbLRxSo+UnwE+NHLbyojEmL F7o1Ob5lGaDksfFszNKpxTouYD4o7YcSd1ichOM7PlCBmHONd6nIg7DnzJsvucM4EiyT m1z4d6PlR0GfJk2gV0VZTk8pt9Gokgq599eorMbUrvRVM5j1QbJKWBgGZQXwZoIdntkx IA2WyPW1bPsxk5+nONmWfrSOKmX2xz5JbICa6MsopSxo/93AePxTz0TnjbwcuQB38Is1 my+w== 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=pIjNjauKEloFgkoYq9O6BSJt9tQlxWkaQev/bhSVIRI=; b=Kugoixc9C50JPkCZCkYDDNNv6ZWmnss9TcRunWhRpTI45s1d0F3xOJDDvkfPGg7tH6 35J6omCz2AFj0ftsnCyMiOJ6vKTCLTLTeWgBoIfHp7Rq/d+grV/RKkM6HvMSelJTLBlX 6vVj2m7Sc9k3gXZH3y9eZ1D+yPJ+qGBtI/QA5ozvkhpCaMWfjhPexiunS6o2pKt/Yy5X 90RwBWN/bkgrxutxfKXaOrWyQ5ka91Pv6DBtZkXS4P3NcM4QG/U0UOv1wIlcCP9C/6xu 9OBuWhskkTCILrAiAUhvO5pqnRwel4OxYaRpYgqQ1zzQIMglqrGIv8owItv/ENCqjBHD 4Yuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EmJ3vv3M; 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 w16si329495plp.329.2019.06.20.11.16.47; Thu, 20 Jun 2019 11:17:01 -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=EmJ3vv3M; 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 S1729620AbfFTSPd (ORCPT + 99 others); Thu, 20 Jun 2019 14:15:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:44342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729406AbfFTSPb (ORCPT ); Thu, 20 Jun 2019 14:15:31 -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 DC64F2082C; Thu, 20 Jun 2019 18:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561054530; bh=NjJ/4uuqZnv3/Az8pb2ngp8cd+vyciN0pchqZBP0SbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EmJ3vv3M1kqL7R92W7/dKK/+wMxykgmYbotzCSq+gpFCjZ3DppQpfjywvHTMbd955 4JH9UW6vg5m9EXXxua6NVcX44L6gzVfAtF8Cy/JncxqrjKdF4eZFHaz9vpBS+gyzAh y4gO6mRfhmG0H9WzbDGy7ljYBos+9qamrr5AxhXA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Igor Russkikh , "David S. Miller" , Sasha Levin Subject: [PATCH 5.1 61/98] net: aquantia: tx clean budget logic error Date: Thu, 20 Jun 2019 19:57:28 +0200 Message-Id: <20190620174352.152564588@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174349.443386789@linuxfoundation.org> References: <20190620174349.443386789@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 31bafc49a7736989e4c2d9f7280002c66536e590 ] In case no other traffic happening on the ring, full tx cleanup may not be completed. That may cause socket buffer to overflow and tx traffic to stuck until next activity on the ring happens. This is due to logic error in budget variable decrementor. Variable is compared with zero, and then post decremented, causing it to become MAX_INT. Solution is remove decrementor from the `for` statement and rewrite it in a clear way. Fixes: b647d3980948e ("net: aquantia: Add tx clean budget and valid budget handling logic") Signed-off-by: Igor Russkikh Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c index e2ffb159cbe2..bf4aa7060f1a 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c @@ -139,10 +139,10 @@ void aq_ring_queue_stop(struct aq_ring_s *ring) bool aq_ring_tx_clean(struct aq_ring_s *self) { struct device *dev = aq_nic_get_dev(self->aq_nic); - unsigned int budget = AQ_CFG_TX_CLEAN_BUDGET; + unsigned int budget; - for (; self->sw_head != self->hw_head && budget--; - self->sw_head = aq_ring_next_dx(self, self->sw_head)) { + for (budget = AQ_CFG_TX_CLEAN_BUDGET; + budget && self->sw_head != self->hw_head; budget--) { struct aq_ring_buff_s *buff = &self->buff_ring[self->sw_head]; if (likely(buff->is_mapped)) { @@ -167,6 +167,7 @@ bool aq_ring_tx_clean(struct aq_ring_s *self) buff->pa = 0U; buff->eop_index = 0xffffU; + self->sw_head = aq_ring_next_dx(self, self->sw_head); } return !!budget; -- 2.20.1