Commit 96f641a7 authored by Li RongQing's avatar Li RongQing Committed by Ben Hutchings

8021q: fix a potential memory leak

[ Upstream commit 916c1689 ]

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: default avatarLi RongQing <roy.qing.li@gmail.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 94fb7252
...@@ -96,8 +96,11 @@ EXPORT_SYMBOL(vlan_dev_vlan_id); ...@@ -96,8 +96,11 @@ EXPORT_SYMBOL(vlan_dev_vlan_id);
static struct sk_buff *vlan_reorder_header(struct sk_buff *skb) 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; return NULL;
}
memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN); memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN);
skb->mac_header += VLAN_HLEN; skb->mac_header += VLAN_HLEN;
return skb; return skb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment