All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Cong Wang <amwang@redhat.com>
Cc: netdev@vger.kernel.org, Saurabh Mohan <saurabh.mohan@vyatta.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [Patch net] vti: remove duplicated code to fix a memory leak
Date: Fri, 28 Jun 2013 22:18:49 -0700	[thread overview]
Message-ID: <20130628221849.16c7ca0e@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <1372482057-12412-1-git-send-email-amwang@redhat.com>

On Sat, 29 Jun 2013 13:00:57 +0800
Cong Wang <amwang@redhat.com> wrote:

> From: Cong Wang <amwang@redhat.com>
> 
> 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: Cong Wang <amwang@redhat.com>
> 
> ---
> diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
> index c118f6b..17cc0ff 100644
> --- a/net/ipv4/ip_vti.c
> +++ b/net/ipv4/ip_vti.c
> @@ -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;

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

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

  reply	other threads:[~2013-06-29  5:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-29  5:00 [Patch net] vti: remove duplicated code to fix a memory leak Cong Wang
2013-06-29  5:18 ` Stephen Hemminger [this message]
2013-06-29  6:20   ` Cong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130628221849.16c7ca0e@nehalam.linuxnetplumber.net \
    --to=stephen@networkplumber.org \
    --cc=amwang@redhat.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=saurabh.mohan@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.