Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1017726imm; Wed, 19 Sep 2018 10:33:56 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZFI2774/GbmgDPO2HMOSmulk640Ujp/1zuig218iMvSRPQfDc+CCJ7ITq43si+dNGcD7R6 X-Received: by 2002:a62:b2d3:: with SMTP id z80-v6mr37824245pfl.79.1537378436387; Wed, 19 Sep 2018 10:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537378436; cv=none; d=google.com; s=arc-20160816; b=if9j1Dg1dgA45MxpQFlXr4hkptLMWkW6D2CimCnpLLkUEsYm7vyUmigxfDhG1rusvY xJsWbb75XgfbiDyIWP+r+uIbI+8sG+8bx6oKJia3HJORCSnK4BJFyIyMNRgCRccMcV16 VeZVv9yTG9E/IzkO/1rTraOe0I320lNU7ByWNkROY8F1fN9RpH6rjTgxy0jpaPnMB9VW pnMeDpamuvSLWBp1XcgsHuThXoDW21o6DWu1DgO7eImsUNcOhHVQ7N8ZliyTb5iJKyc9 12PRNZewt9wK8/tzE6dmIcqmKi17q3PUv0eSYHqljZ9sSNEdvVWQ0yjCrshEZjExw+KN 0sxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=keo3iqwFLp/2OeXhXMq8cl1vo7YI+OGZKF+3V0o0fYY=; b=W3yecJhuGWFOiLw1t5h38nYwhJ61di09+DJypeInvZXs3VYJlPaxpixoE+JJXDdK69 esjKgGdxZMvDeHuSm2IwKJ1lZ7GAru0sHA/zY1eJWMjwwZHKDbNGH507MDhsbMjF8U0Z pFwMOmVW3Iu1/EZNbV8KrGFmh/6TRTJguuU0KSQFP5gDf6o7Wt8OXjIC9rhecl/qAaVh E1vC0DnwQd60+/YlLv0I15lHXQd8uhXAu8oeqdPhjsKuupT0yym19IFr6ZtYfvwtZ+IG 4oEixIDxH74SAxg6GItbXeHcWiheGALiaWnXy6RZf8FoMh01dQ2zJ76JciKx7E+1iK9N JJIQ== ARC-Authentication-Results: i=1; mx.google.com; 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 t13-v6si21395323pgl.461.2018.09.19.10.33.41; Wed, 19 Sep 2018 10:33:56 -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; 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 S1733119AbeISXKD (ORCPT + 99 others); Wed, 19 Sep 2018 19:10:03 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12207 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727628AbeISXKD (ORCPT ); Wed, 19 Sep 2018 19:10:03 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 0F7EF6A61CF53; Thu, 20 Sep 2018 01:31:03 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.399.0; Thu, 20 Sep 2018 01:30:58 +0800 From: Salil Mehta To: CC: , , , , , , Subject: [PATCH net-next 02/12] net: hns3: Add unlikely for buf_num check Date: Wed, 19 Sep 2018 18:29:48 +0100 Message-ID: <20180919172958.12992-3-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180919172958.12992-1-salil.mehta@huawei.com> References: <20180919172958.12992-1-salil.mehta@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peng Li This patch adds unlikely for buf_num check. Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 052b7fb..837c6d6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1074,7 +1074,7 @@ static int hns3_nic_maybe_stop_tx(struct sk_buff **out_skb, int *bnum, /* No. of segments (plus a header) */ buf_num = skb_shinfo(skb)->nr_frags + 1; - if (buf_num > ring_space(ring)) + if (unlikely(ring_space(ring) < buf_num)) return -EBUSY; *bnum = buf_num; -- 2.7.4