From patchwork Fri Aug 18 11:31:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 110379 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp786705qge; Fri, 18 Aug 2017 04:32:41 -0700 (PDT) X-Received: by 10.84.231.203 with SMTP id g11mr9423864pln.199.1503055960963; Fri, 18 Aug 2017 04:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503055960; cv=none; d=google.com; s=arc-20160816; b=q/W4AqcI/CjxYQIToo75+3Xd4KfYWxjy9rdQ0iAtrxiNoB7W+G9QZiXjc4XwTK/CSg GWVxOFc6NeXGHOJ03CmXw/67Odi91EC5cn5fXW6xoo0IfddEcdJEKbPw6jWoJu5AUYEA lo68+oU88+w1LHnB/tbKTiGHyqd0nl1gi3Xcgrb/TmWS55T1lBUMeyso2uR2GBibmH66 DSGzTGHUlZXTCuzaQY0E0lJCmh/Pas5NhogM95R6zjdOiHDbDS5s3hxS30cKODwcAS0V EHE6RzkX03p+dW9LooDJIpuLLZLYcLiLW4lhbkHkzYh9jBC2zSBLLHLwkadecz+LiFEm lDcw== 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:arc-authentication-results; bh=foiEBnjs9IOdUAwlR38glVuaXGsc12rtdVLchq77o+A=; b=S3zot524n+CTo+VwTLsMTp/WiRK+3SqD9Hq6pGYr/3NWH1AYKrW0zF/9Zvh6VvNmGS LMBL1DNBFDrX4F2ECjfSi6MPwyO/3npP5SaAILw+HMLpk2riWjL4Rj8oRfIX79P6S26n OZelt5IuoDjP0CK+bAXapWakmzMx+NcJJ4eKxlc32tqp65olrnbU681QwcndlntNBnGP TIAE6YL66d+KZOoECL1j8Sf8OUcacLyAcR8Zdq3QssCeypevpnl3MdMt7DxQSWqpIG7I E7CbcXII2o6H0yk8obvRAObc4hTWs0ZemNWuhOXifazgsqVruxfhFq8gYH7d//M/58My RRwQ== 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 p1si3778643pld.308.2017.08.18.04.32.40; Fri, 18 Aug 2017 04:32:40 -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 S1751660AbdHRLcj (ORCPT + 26 others); Fri, 18 Aug 2017 07:32:39 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4072 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751267AbdHRLce (ORCPT ); Fri, 18 Aug 2017 07:32:34 -0400 Received: from 172.30.72.59 (EHLO DGGEMS414-HUB.china.huawei.com) ([172.30.72.59]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DFM57993; Fri, 18 Aug 2017 19:32:32 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.203.181.151) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.301.0; Fri, 18 Aug 2017 19:32:22 +0800 From: Salil Mehta To: CC: , , , , , , , , Subject: [PATCH net-next 3/3] net: hns3: Fixes the static check warning due to missing unsupp L3 proto check Date: Fri, 18 Aug 2017 12:31:39 +0100 Message-ID: <20170818113139.153200-4-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20170818113139.153200-1-salil.mehta@huawei.com> References: <20170818113139.153200-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.203.181.151] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.5996D050.00B2, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d8c602129fe403ab9bf2056459c2544d Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch fixes the static check warning due to missing handling leg of unsupported L3 protocol type in the hns3_get_l4_protocol() function. Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Reported-by: Dan Carpenter Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c index b12730a..e731f87 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c @@ -436,8 +436,8 @@ static int hns3_set_tso(struct sk_buff *skb, u32 *paylen, return 0; } -static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, - u8 *il4_proto) +static int hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, + u8 *il4_proto) { union { struct iphdr *v4; @@ -461,6 +461,8 @@ static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, &l4_proto_tmp, &frag_off); } else if (skb->protocol == htons(ETH_P_IP)) { l4_proto_tmp = l3.v4->protocol; + } else { + return -EINVAL; } *ol4_proto = l4_proto_tmp; @@ -468,7 +470,7 @@ static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, /* tunnel packet */ if (!skb->encapsulation) { *il4_proto = 0; - return; + return 0; } /* find inner header point */ @@ -486,6 +488,8 @@ static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto, } *il4_proto = l4_proto_tmp; + + return 0; } static void hns3_set_l2l3l4_len(struct sk_buff *skb, u8 ol4_proto, @@ -757,7 +761,9 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv, protocol = vlan_get_protocol(skb); skb->protocol = protocol; } - hns3_get_l4_protocol(skb, &ol4_proto, &il4_proto); + ret = hns3_get_l4_protocol(skb, &ol4_proto, &il4_proto); + if (ret) + return ret; hns3_set_l2l3l4_len(skb, ol4_proto, il4_proto, &type_cs_vlan_tso, &ol_type_vlan_len_msec);