Commit 916c1689a09bc1ca81f2d7a34876f8d35aadd11b

Authored by Li RongQing
Committed by David S. Miller
1 parent 1b0608fd9b

8021q: fix a potential memory leak

skb_cow called in vlan_reorder_header does not free the skb when it failed,
and vlan_reorder_header returns NULL to reset original skb when it is called
in vlan_untag, lead to a memory leak.

Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 4 additions and 1 deletions Side-by-side Diff

net/8021q/vlan_core.c
... ... @@ -114,8 +114,11 @@
114 114  
115 115 static struct sk_buff *vlan_reorder_header(struct sk_buff *skb)
116 116 {
117   - if (skb_cow(skb, skb_headroom(skb)) < 0)
  117 + if (skb_cow(skb, skb_headroom(skb)) < 0) {
  118 + kfree_skb(skb);
118 119 return NULL;
  120 + }
  121 +
119 122 memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN);
120 123 skb->mac_header += VLAN_HLEN;
121 124 return skb;