From c8e694c6f0a1330cdcd11b3601a2a5c58fc00df9 Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Mon, 4 Apr 2022 12:18:44 +0530 Subject: [PATCH] api.c: add check for empty cgroup v2 controller There can be cgroup v2 cgroup with no controllers attached to it and while checking for enabled controllers always return true in cgroupv2_controller_enabled() for such cgroups. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- src/api.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api.c b/src/api.c index ca71ef29..f5b6d303 100644 --- a/src/api.c +++ b/src/api.c @@ -1770,6 +1770,10 @@ STATIC int cgroupv2_controller_enabled(const char * const cg_name, if (version != CGROUP_V2) return 0; + if (ctrl_name == NULL) + /* cgroup v2 supports cgroups with no controllers. */ + return 0; + if (strncmp(cg_name, "/", strlen(cg_name)) == 0) /* * The root cgroup has been requested. All version 2 -- 2.47.2