ip6_gre: fix a dst leak in ip6erspan_tunnel_xmit
authorXin Long <lucien.xin@gmail.com>
Fri, 13 Sep 2019 09:45:47 +0000 (17:45 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 Sep 2019 07:08:18 +0000 (09:08 +0200)
In ip6erspan_tunnel_xmit(), if the skb will not be sent out, it has to
be freed on the tx_err path. Otherwise when deleting a netns, it would
cause dst/dev to leak, and dmesg shows:

  unregister_netdevice: waiting for lo to become free. Usage count = 1

Fixes: ef7baf5e083c ("ip6_gre: add ip6 erspan collect_md mode")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/ip6_gre.c

index dd2d0b9..d5779d6 100644 (file)
@@ -968,7 +968,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
                if (unlikely(!tun_info ||
                             !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
                             ip_tunnel_info_af(tun_info) != AF_INET6))
-                       return -EINVAL;
+                       goto tx_err;
 
                key = &tun_info->key;
                memset(&fl6, 0, sizeof(fl6));