From: Eric Dumazet <eric.dumazet@gmail.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev <netdev@vger.kernel.org>,
Eric Dumazet <edumazet@google.com>,
Eric Dumazet <eric.dumazet@gmail.com>,
syzbot <syzkaller@googlegroups.com>,
Tony Lu <tonylu@linux.alibaba.com>,
Dust Li <dust.li@linux.alibaba.com>
Subject: [PATCH net] net/smc: fix a memory leak in smc_sysctl_net_exit()
Date: Fri, 25 Mar 2022 09:50:21 -0700 [thread overview]
Message-ID: <20220325165021.570708-1-eric.dumazet@gmail.com> (raw)
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);
}
--
2.35.1.1021.g381101b075-goog
next reply other threads:[~2022-03-25 16:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-25 16:50 Eric Dumazet [this message]
2022-03-26 21:20 ` [PATCH net] net/smc: fix a memory leak in smc_sysctl_net_exit() patchwork-bot+netdevbpf
2022-03-28 1:58 ` Tony Lu
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=20220325165021.570708-1-eric.dumazet@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=dust.li@linux.alibaba.com \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=syzkaller@googlegroups.com \
--cc=tonylu@linux.alibaba.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.