Skip to content

Commit

Permalink
net/smc: fix a memory leak in smc_sysctl_net_exit()
Browse files Browse the repository at this point in the history
Recently added smc_sysctl_net_exit() forgot to free
the memory allocated from smc_sysctl_net_init()
for non initial network namespace.

Fixes: 462791b ("net/smc: add sysctl interface for SMC")
Signed-off-by: Eric Dumazet <[email protected]>
Reported-by: syzbot <[email protected]>
Cc: Tony Lu <[email protected]>
Cc: Dust Li <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Mar 26, 2022
1 parent 5c7e49b commit 5ae6acf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions net/smc/smc_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 5ae6acf

Please sign in to comment.