From: Kamalesh Babulal Date: Mon, 4 Apr 2022 06:48:44 +0000 (+0530) Subject: api.c: add check for empty cgroup v2 controller X-Git-Tag: v3.0~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8e694c6f0a1330cdcd11b3601a2a5c58fc00df9;p=thirdparty%2Flibcgroup.git 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 --- 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