diff options
author | Tony Lindgren <tony@atomide.com> | 2022-09-06 09:45:27 +0300 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2022-09-06 09:45:27 +0300 |
commit | 2a906db2824b75444982f5e9df870106982afca8 (patch) | |
tree | 8cda7a970356f63f2a9d3246ca69ef16220041d3 /net/unix/sysctl_net_unix.c | |
parent | 2eb502f496f7764027b7958d4e74356fed918059 (diff) | |
parent | 6a6d9ecff14a2a46c1deeffa3eb3825349639bdd (diff) |
Merge branch 'am5748-fix' into fixes
Diffstat (limited to 'net/unix/sysctl_net_unix.c')
-rw-r--r-- | net/unix/sysctl_net_unix.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c index 01d44e2598e2..500129aa710c 100644 --- a/net/unix/sysctl_net_unix.c +++ b/net/unix/sysctl_net_unix.c @@ -26,11 +26,16 @@ int __net_init unix_sysctl_register(struct net *net) { struct ctl_table *table; - table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL); - if (table == NULL) - goto err_alloc; + if (net_eq(net, &init_net)) { + table = unix_table; + } else { + table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL); + if (!table) + goto err_alloc; + + table[0].data = &net->unx.sysctl_max_dgram_qlen; + } - table[0].data = &net->unx.sysctl_max_dgram_qlen; net->unx.ctl = register_net_sysctl(net, "net/unix", table); if (net->unx.ctl == NULL) goto err_reg; @@ -38,7 +43,8 @@ int __net_init unix_sysctl_register(struct net *net) return 0; err_reg: - kfree(table); + if (!net_eq(net, &init_net)) + kfree(table); err_alloc: return -ENOMEM; } @@ -49,5 +55,6 @@ void unix_sysctl_unregister(struct net *net) table = net->unx.ctl->ctl_table_arg; unregister_net_sysctl_table(net->unx.ctl); - kfree(table); + if (!net_eq(net, &init_net)) + kfree(table); } |