Skip to content

Commit 916c168

Browse files
Li RongQingdavem330
authored andcommitted
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>
1 parent 1b0608f commit 916c168

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/8021q/vlan_core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ EXPORT_SYMBOL(vlan_dev_vlan_proto);
114114

115115
static struct sk_buff *vlan_reorder_header(struct sk_buff *skb)
116116
{
117-
if (skb_cow(skb, skb_headroom(skb)) < 0)
117+
if (skb_cow(skb, skb_headroom(skb)) < 0) {
118+
kfree_skb(skb);
118119
return NULL;
120+
}
121+
119122
memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN);
120123
skb->mac_header += VLAN_HLEN;
121124
return skb;

0 commit comments

Comments
 (0)