vti: remove duplicated code to fix a memory leak
Subsystems (4)
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)
---
net/ipv4/ip_vti.c +0 -7
@@ -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 ;
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->tstatstwice: invti_fb_tunnel_init()and invti_tunnel_init(), this lead to a memory leak ofdev->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]>Signed-off-by Cong Wang <[email protected]>---
net/ipv4/ip_vti.c +0
-3@@ -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
-4iph->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.
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!