net/smc: fix a memory leak in smc_sysctl_net_exit()

Recently added smc_sysctl_net_exit() forgot to free
the memory allocated from smc_sysctl_net_init()
for non initial network namespace.

Fixes: 462791bbfa ("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>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eric Dumazet 2022-03-25 09:50:21 -07:00 committed by David S. Miller
parent 5c7e49be96
commit 5ae6acf1d0
1 changed files with 5 additions and 0 deletions

View File

@ -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);
}