Skip to content

Commit 9e7c73c

Browse files
committed
kernel: pid_namespace: simplify sysctls with register_sysctl()
register_sysctl_paths() is only required if your child (directories) have entries and pid_namespace does not. So use register_sysctl_init() instead where we don't care about the return value and use register_sysctl() where we do. Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Acked-by: Jeff Xu <jeffxu@google.com> Link: https://lore.kernel.org/r/20230302202826.776286-9-mcgrof@kernel.org
1 parent 348551d commit 9e7c73c

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

kernel/pid_namespace.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ static struct ctl_table pid_ns_ctl_table[] = {
314314
},
315315
{ }
316316
};
317-
static struct ctl_path kern_path[] = { { .procname = "kernel", }, { } };
318317
#endif /* CONFIG_CHECKPOINT_RESTORE */
319318

320319
int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
@@ -473,7 +472,7 @@ static __init int pid_namespaces_init(void)
473472
pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC | SLAB_ACCOUNT);
474473

475474
#ifdef CONFIG_CHECKPOINT_RESTORE
476-
register_sysctl_paths(kern_path, pid_ns_ctl_table);
475+
register_sysctl_init("kernel", pid_ns_ctl_table);
477476
#endif
478477

479478
register_pid_ns_sysctl_table_vm();

kernel/pid_sysctl.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ static struct ctl_table pid_ns_ctl_table_vm[] = {
4646
},
4747
{ }
4848
};
49-
static struct ctl_path vm_path[] = { { .procname = "vm", }, { } };
5049
static inline void register_pid_ns_sysctl_table_vm(void)
5150
{
52-
register_sysctl_paths(vm_path, pid_ns_ctl_table_vm);
51+
register_sysctl("vm", pid_ns_ctl_table_vm);
5352
}
5453
#else
5554
static inline void initialize_memfd_noexec_scope(struct pid_namespace *ns) {}

0 commit comments

Comments
 (0)