Skip to contentSkip to conversation

vti: remove duplicated code to fix a memory leak

PATCH In review Cong Wang 2 participants 3 messages Jun 29, 2013

Subsystems (4)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 vti: remove duplicated code to fix a memory leak

From: Cong Wang <[email protected]>

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 <[email protected]>
Cc Saurabh Mohan <[email protected]>
Cc "David S. Miller" <[email protected]>

---

net/ipv4/ip_vti.c +0 -7
index c118f6b..17cc0ff 100644
@@ -606,17 +606,10 @@ static int __net_init vti_fb_tunnel_init(struct net_device *dev)
 	struct iphdr *iph = &tunnel->parms.iph;
 	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->protocol		= IPPROTO_IPIP;
 	iph->ihl		= 5;
 
-	dev->tstats = alloc_percpu(struct pcpu_tstats);
-	if (!dev->tstats)
-		return -ENOMEM;
-
 	dev_hold(dev);
 	rcu_assign_pointer(ipn->tunnels_wc[0], tunnel);
 	return 0;
Acked-by on v1 1/1
#1 lore raw
Quoted 28 lines · On Sat, 29 Jun 2013 13:00:57 +0800 Cong Wang <[email protected]> wrote:

From: Cong Wang <[email protected]>

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 <[email protected]>
Cc Saurabh Mohan <[email protected]>
Cc "David S. Miller" <[email protected]>

---

net/ipv4/ip_vti.c +0 -3
index c118f6b..17cc0ff 100644
@@ -606,17 +606,10 @@ static int __net_init vti_fb_tunnel_init(struct net_device *dev)
 	struct iphdr *iph = &tunnel->parms.iph;
 	struct vti_net *ipn = net_generic(dev_net(dev), vti_net_id);
 
-	tunnel->dev = dev;
-	strcpy(tunnel->parms.name, dev->name);
-
 	iph->version		= 4;

net/ipv4/ip_vti.c static int __net_init vti_fb_tunnel_init(struct net_device *dev) · line 615

Quoted 10 lines
net/ipv4/ip_vti.c +0 -4
 	iph->protocol		= IPPROTO_IPIP;
 	iph->ihl		= 5;
 
-	dev->tstats = alloc_percpu(struct pcpu_tstats);
-	if (!dev->tstats)
-		return -ENOMEM;
-
 	dev_hold(dev);
 	rcu_assign_pointer(ipn->tunnels_wc[0], tunnel);
 	return 0;

The fix looks correct, looks like an oversight when the generic tunnel infratructure was added.

author
#2 lore raw
Quoted 3 lines · Stephen Hemminger

The fix looks correct, looks like an oversight when the generic tunnel infratructure was added.

Yeah, I am trying to switch vti tunnel using generic tunnel code.

Thanks!