From bae841ff46b50f21cd25bbd9debde0b81ab4931a Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Fri, 25 Mar 2022 09:50:21 -0700 Subject: [PATCH] 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: 1b821d34177b ("net/smc: add sysctl interface for SMC") Signed-off-by: Eric Dumazet Reported-by: syzbot Cc: Tony Lu Cc: Dust Li Signed-off-by: David S. Miller --- 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 bae19419e7553..cf3ab1334c009 100644 --- a/net/smc/smc_sysctl.c +++ b/net/smc/smc_sysctl.c @@ -61,5 +61,10 @@ err_alloc: 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.39.5