Skip to content

Commit

Permalink
8021q: fix a potential memory leak
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Li RongQing authored and davem330 committed Jun 21, 2014
1 parent 1b0608f commit 916c168
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/8021q/vlan_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ EXPORT_SYMBOL(vlan_dev_vlan_proto);

static struct sk_buff *vlan_reorder_header(struct sk_buff *skb)
{
if (skb_cow(skb, skb_headroom(skb)) < 0)
if (skb_cow(skb, skb_headroom(skb)) < 0) {
kfree_skb(skb);
return NULL;
}

memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN);
skb->mac_header += VLAN_HLEN;
return skb;
Expand Down

0 comments on commit 916c168

Please sign in to comment.