gre: fix a possible skb leak
[firefly-linux-kernel-4.4.55.git] / net / ipv4 / gre.c
index cc22363965d2a9a66d08e9368cc4e62e2ccea08a..7856d1651d054325a67d1ac4847204be45bbceaa 100644 (file)
@@ -150,13 +150,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
                csum = false;
 
        /* setup inner skb. */
-       if (greh->protocol == htons(ETH_P_TEB)) {
-               struct ethhdr *eth = (struct ethhdr *)skb_inner_mac_header(skb);
-               skb->protocol = eth->h_proto;
-       } else {
-               skb->protocol = greh->protocol;
-       }
-
+       skb->protocol = greh->protocol;
        skb->encapsulation = 0;
 
        if (unlikely(!pskb_may_pull(skb, ghl)))
@@ -184,7 +178,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
 
                                err = __skb_linearize(skb);
                                if (err) {
-                                       kfree_skb(segs);
+                                       kfree_skb_list(segs);
                                        segs = ERR_PTR(err);
                                        goto out;
                                }