All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lu <tonylu@linux.alibaba.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev <netdev@vger.kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	syzbot <syzkaller@googlegroups.com>,
	Dust Li <dust.li@linux.alibaba.com>
Subject: Re: [PATCH net] net/smc: fix a memory leak in smc_sysctl_net_exit()
Date: Mon, 28 Mar 2022 09:58:58 +0800	[thread overview]
Message-ID: <YkEWYutckbyQoa62@TonyMac-Alibaba> (raw)
In-Reply-To: <20220325165021.570708-1-eric.dumazet@gmail.com>

On Fri, Mar 25, 2022 at 09:50:21AM -0700, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> Recently added smc_sysctl_net_exit() forgot to free
> the memory allocated from smc_sysctl_net_init()
> for non initial network namespace.
> 
> Fixes: 462791bbfa35 ("net/smc: add sysctl interface for SMC")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: syzbot <syzkaller@googlegroups.com>
> Cc: Tony Lu <tonylu@linux.alibaba.com>
> Cc: Dust Li <dust.li@linux.alibaba.com>
> ---
>  net/smc/smc_sysctl.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c
> index bae19419e7553222d74c2ae178fd5a2b6116679b..cf3ab1334c009a1a0539b2c228c4503ae391d89b 100644
> --- a/net/smc/smc_sysctl.c
> +++ b/net/smc/smc_sysctl.c
> @@ -61,5 +61,10 @@ int __net_init smc_sysctl_net_init(struct net *net)
>  
>  void __net_exit smc_sysctl_net_exit(struct net *net)
>  {
> +	struct ctl_table *table;
> +
> +	table = net->smc.smc_hdr->ctl_table_arg;
>  	unregister_net_sysctl_table(net->smc.smc_hdr);
> +	if (!net_eq(net, &init_net))
> +		kfree(table);
>  }

Thanks a lot for fixing this issue, this is my fault.

Tony Lu

      parent reply	other threads:[~2022-03-28  1:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-25 16:50 [PATCH net] net/smc: fix a memory leak in smc_sysctl_net_exit() Eric Dumazet
2022-03-26 21:20 ` patchwork-bot+netdevbpf
2022-03-28  1:58 ` Tony Lu [this message]

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=YkEWYutckbyQoa62@TonyMac-Alibaba \
    --to=tonylu@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=dust.li@linux.alibaba.com \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzkaller@googlegroups.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.