Merge branch 'work.csum_and_copy' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / net / core / skbuff.c
index 48dd475..5cd6d48 100644 (file)
@@ -820,6 +820,7 @@ void skb_tx_error(struct sk_buff *skb)
 }
 EXPORT_SYMBOL(skb_tx_error);
 
+#ifdef CONFIG_TRACEPOINTS
 /**
  *     consume_skb - free an skbuff
  *     @skb: buffer to free
@@ -837,6 +838,7 @@ void consume_skb(struct sk_buff *skb)
        __kfree_skb(skb);
 }
 EXPORT_SYMBOL(consume_skb);
+#endif
 
 /**
  *     consume_stateless_skb - free an skbuff, assuming it is stateless
@@ -5419,8 +5421,8 @@ struct sk_buff *skb_vlan_untag(struct sk_buff *skb)
        skb = skb_share_check(skb, GFP_ATOMIC);
        if (unlikely(!skb))
                goto err_free;
-
-       if (unlikely(!pskb_may_pull(skb, VLAN_HLEN)))
+       /* We may access the two bytes after vlan_hdr in vlan_set_encap_proto(). */
+       if (unlikely(!pskb_may_pull(skb, VLAN_HLEN + sizeof(unsigned short))))
                goto err_free;
 
        vhdr = (struct vlan_hdr *)skb->data;
@@ -5621,7 +5623,7 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
        lse->label_stack_entry = mpls_lse;
        skb_postpush_rcsum(skb, lse, MPLS_HLEN);
 
-       if (ethernet)
+       if (ethernet && mac_len >= ETH_HLEN)
                skb_mod_eth_type(skb, eth_hdr(skb), mpls_proto);
        skb->protocol = mpls_proto;
 
@@ -5661,7 +5663,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
        skb_reset_mac_header(skb);
        skb_set_network_header(skb, mac_len);
 
-       if (ethernet) {
+       if (ethernet && mac_len >= ETH_HLEN) {
                struct ethhdr *hdr;
 
                /* use mpls_hdr() to get ethertype to account for VLANs. */
@@ -5988,9 +5990,13 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,
        if (skb_has_frag_list(skb))
                skb_clone_fraglist(skb);
 
-       if (k == 0) {
-               /* split line is in frag list */
-               pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask);
+       /* split line is in frag list */
+       if (k == 0 && pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask)) {
+               /* skb_frag_unref() is not needed here as shinfo->nr_frags = 0. */
+               if (skb_has_frag_list(skb))
+                       kfree_skb_list(skb_shinfo(skb)->frag_list);
+               kfree(data);
+               return -ENOMEM;
        }
        skb_release_data(skb);