summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorSalil2017-08-18 13:31:39 +0200
committerDavid S. Miller2017-08-18 19:31:56 +0200
commit1898d4e404a5f0095071fa3ae178a1d066360fbb (patch)
tree572d7c610abcd9b48aab5857bfda25c763dee681 /drivers/net
parentnet: hns3: Fixes the static checker error warning in hns3_get_link_ksettings() (diff)
downloadkernel-qcow2-linux-1898d4e404a5f0095071fa3ae178a1d066360fbb.tar.gz
kernel-qcow2-linux-1898d4e404a5f0095071fa3ae178a1d066360fbb.tar.xz
kernel-qcow2-linux-1898d4e404a5f0095071fa3ae178a1d066360fbb.zip
net: hns3: Fixes the static check warning due to missing unsupp L3 proto check
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 <dan.carpenter@oracle.com> Signed-off-by: Salil Mehta <salil.mehta@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c14
1 files 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 b12730a23c25..e731f87f3c46 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);