Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab6c7a0a authored by Cong Wang's avatar Cong Wang Committed by David S. Miller
Browse files

vti: remove duplicated code to fix a memory leak



vti module allocates dev->tstats twice: in vti_fb_tunnel_init()
and in vti_tunnel_init(), this lead to a memory leak of
dev->tstats.

Just remove the duplicated operations in vti_fb_tunnel_init().

(candidate for -stable)

Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Saurabh Mohan <saurabh.mohan@vyatta.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: default avatarCong Wang <amwang@redhat.com>
Acked-by: default avatarStephen Hemminger <stephen@networkplumber.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6c734fb8
Loading
Loading
Loading
Loading
+0 −7
Original line number Original line Diff line number Diff line
@@ -606,17 +606,10 @@ static int __net_init vti_fb_tunnel_init(struct net_device *dev)
	struct iphdr *iph = &tunnel->parms.iph;
	struct iphdr *iph = &tunnel->parms.iph;
	struct vti_net *ipn = net_generic(dev_net(dev), vti_net_id);
	struct vti_net *ipn = net_generic(dev_net(dev), vti_net_id);


	tunnel->dev = dev;
	strcpy(tunnel->parms.name, dev->name);

	iph->version		= 4;
	iph->version		= 4;
	iph->protocol		= IPPROTO_IPIP;
	iph->protocol		= IPPROTO_IPIP;
	iph->ihl		= 5;
	iph->ihl		= 5;


	dev->tstats = alloc_percpu(struct pcpu_tstats);
	if (!dev->tstats)
		return -ENOMEM;

	dev_hold(dev);
	dev_hold(dev);
	rcu_assign_pointer(ipn->tunnels_wc[0], tunnel);
	rcu_assign_pointer(ipn->tunnels_wc[0], tunnel);
	return 0;
	return 0;