Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp176295imd; Wed, 31 Oct 2018 16:51:22 -0700 (PDT) X-Google-Smtp-Source: AJdET5cw1Fkkg08swlfXDy7Ohe4kCe69eC2aadBQSxY976Et9eY/V/Jjp58dRFn9cEJY1CkMqMRo X-Received: by 2002:a17:902:904a:: with SMTP id w10-v6mr5194092plz.225.1541029882126; Wed, 31 Oct 2018 16:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029882; cv=none; d=google.com; s=arc-20160816; b=hl37N/751WHVZ2SyU3EIr90vDNGwHvqUlNIFkGTby/SHHv2pVw2MpRCipqYn10mYZP M9Oe7T4JldE1OH2BvVddy5IPAQ8IFNsOT91ARczO1b7pqznYGgMGXF0PgJFtcJhrF88b i0Hx7gzhzptQE4L6VHnF+TV1kjrAytfNIM7jOf/g9nq1nQWhxLiERSS+UUcIgeNaGTAd 21YOorX3odJbe8/ONzNKurr6hHVU/Ne+MostVetorBQW/ytS3bvofEK2UYAq96LmTIOw 7rGMdJOrPfIJ5c4nVYTZKIvMq6RRujFypI9Ldh824EOqCGvEzXMQKbQkuK1LS6Lglyxm RM/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=IlT7NiDshaiYCaHLubXo/Hlp/RYEaAiENsDrO5r6BdM=; b=JOeyTnADl/mtw4kADqFeCMftiu+4/Yv+Z2DT8o7oKZ0tZieOx9+nVYifaSIz4T6Vhh 7kqQQtujjpjwkGnBSf2VxNONye4m2Jg/CIssat6VYsG7TUZ1rYr2S1nDzj+/fRYH9P+X kLE+3JGJ98YsDV2jjIdMHR54j34ZMQyH2OkFzMGwah4LVPrnmJjSFvz9LKLP0fsufS8W swsswipHDVE7mzKT+k/P6NOSBF5fBCbJrQcLXEXFzXwt7u63JfFisQwaKpDTIUyPJwJn 0He5otS2Aq8wyYw603B2ca+Gwxs1yb9uecFDo006CRUqV7LRiVJtQ3T/tqpN8yhh6Fm2 C+bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GGJ80Xzf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si30273986pgn.100.2018.10.31.16.51.06; Wed, 31 Oct 2018 16:51:22 -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=GGJ80Xzf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728211AbeKAIGk (ORCPT + 99 others); Thu, 1 Nov 2018 04:06:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:53694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728133AbeKAIGj (ORCPT ); Thu, 1 Nov 2018 04:06:39 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 02CE120821; Wed, 31 Oct 2018 23:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027188; bh=0piVUUi+GSA2xIrRVmtZzaCTB2jy4xFi6NYBGTQCSic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GGJ80Xzf+MUMDHnijjkdTWn4cUKVXCtY8e7JJJ7CMtXzVHzHnRFidZ2CXwsm4mvl+ suoxERpW6aAXFegd57gOciyKAg/kF8rtAdrlvHo5ZRT+qv88eC202y80Jm+WfYwqwo vuaxhVn2+o75UQ5+eBKQ6lx+Neb1c9wPQ8I/mZpc= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jian Shen , Peng Li , Salil Mehta , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.19 051/146] net: hns3: Fix ets validate issue Date: Wed, 31 Oct 2018 19:04:06 -0400 Message-Id: <20181031230541.28822-51-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jian Shen [ Upstream commit adefc0a2ff465f4ac4a88450fe69d336c8b074c5 ] There is a defect in hclge_ets_validate(). If each member of tc_tsa is not IEEE_8021QAZ_TSA_ETS, the variable total_ets_bw won't be updated. In this case, the check for value of total_ets_bw will fail. This patch fixes it by checking total_ets_bw only after it has been updated. Fixes: cacde272dd00 ("net: hns3: Add hclge_dcb module for the support of DCB feature") Signed-off-by: Jian Shen Signed-off-by: Peng Li Signed-off-by: Salil Mehta Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c index f08ebb7caaaf..92f19384e258 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c @@ -73,6 +73,7 @@ static int hclge_ieee_getets(struct hnae3_handle *h, struct ieee_ets *ets) static int hclge_ets_validate(struct hclge_dev *hdev, struct ieee_ets *ets, u8 *tc, bool *changed) { + bool has_ets_tc = false; u32 total_ets_bw = 0; u8 max_tc = 0; u8 i; @@ -100,13 +101,14 @@ static int hclge_ets_validate(struct hclge_dev *hdev, struct ieee_ets *ets, *changed = true; total_ets_bw += ets->tc_tx_bw[i]; - break; + has_ets_tc = true; + break; default: return -EINVAL; } } - if (total_ets_bw != BW_PERCENT) + if (has_ets_tc && total_ets_bw != BW_PERCENT) return -EINVAL; *tc = max_tc + 1; -- 2.17.1