Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ip6_gre: fix potential memory leak in ip6erspan_rcv

If md is NULL, tun_dst must be freed, otherwise it will cause memory
leak.

Fixes: ef7baf5e083c ("ip6_gre: add ip6 erspan collect_md mode")
Cc: William Tu <u9012063@gmail.com>
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Haishuang Yan and committed by
David S. Miller
afb4c97d 50670b6e

+3 -1
+3 -1
net/ipv6/ip6_gre.c
··· 550 550 551 551 info = &tun_dst->u.tun_info; 552 552 md = ip_tunnel_info_opts(info); 553 - if (!md) 553 + if (!md) { 554 + dst_release((struct dst_entry *)tun_dst); 554 555 return PACKET_REJECT; 556 + } 555 557 556 558 memcpy(md, pkt_md, sizeof(*md)); 557 559 md->version = ver;