From 44ac441a51a77717e7e66d75591be3aa971a7455 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Fri, 8 Jul 2022 16:28:58 +0000 Subject: af_unix: fix unix_sysctl_register() error path We want to kfree(table) if @table has been kmalloced, ie for non initial network namespace. Fixes: 849d5aa3a1d8 ("af_unix: Do not call kmemdup() for init_net's sysctl table.") Signed-off-by: Eric Dumazet Cc: Kuniyuki Iwashima Cc: Eric W. Biederman Acked-by: Kuniyuki Iwashima Signed-off-by: David S. Miller --- net/unix/sysctl_net_unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/unix/sysctl_net_unix.c') diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c index 3f1fdffd6092..500129aa710c 100644 --- a/net/unix/sysctl_net_unix.c +++ b/net/unix/sysctl_net_unix.c @@ -43,7 +43,7 @@ int __net_init unix_sysctl_register(struct net *net) return 0; err_reg: - if (net_eq(net, &init_net)) + if (!net_eq(net, &init_net)) kfree(table); err_alloc: return -ENOMEM; -- cgit v1.2.3