[PATCH] cgroup: Avoid warning when procfs is disabled
From: Karl Mehltretter
Date: Mon Oct 12 2026 - 01:42:46 EST
With CGROUPS=y and PROC_FS=n, proc_create_single() returns NULL and
cgroup initialization warns during every boot.
Only check creation of /proc/cgroups when procfs is enabled.
Fixes: 035f4f510583 ("cgroup: replace error handling in cgroup_init() with WARN_ON()s")
Assisted-by: LLM
Signed-off-by: Karl Mehltretter <kmehltretter@xxxxxxxxx>
---
kernel/cgroup/cgroup.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 227d09704ca5..567afb75a4ec 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -6612,7 +6612,9 @@ int __init cgroup_init(void)
WARN_ON(sysfs_create_mount_point(fs_kobj, "cgroup"));
WARN_ON(register_filesystem(&cgroup_fs_type));
WARN_ON(register_filesystem(&cgroup2_fs_type));
- WARN_ON(!proc_create_single("cgroups", 0, NULL, proc_cgroupstats_show));
+ if (IS_ENABLED(CONFIG_PROC_FS))
+ WARN_ON(!proc_create_single("cgroups", 0, NULL,
+ proc_cgroupstats_show));
#ifdef CONFIG_CPUSETS_V1
WARN_ON(register_filesystem(&cpuset_fs_type));
#endif
--
2.53.0