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: 9908365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A342160382 for ; Fri, 18 Aug 2017 11:33:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9766928C84 for ; Fri, 18 Aug 2017 11:33:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C08F28C87; Fri, 18 Aug 2017 11:33:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18FBB28C84 for ; Fri, 18 Aug 2017 11:33:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751549AbdHRLci (ORCPT ); Fri, 18 Aug 2017 07:32:38 -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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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);