]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
api.c: add check for empty cgroup v2 controller
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 4 Apr 2022 06:48:44 +0000 (12:18 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 20 Apr 2022 15:23:33 +0000 (09:23 -0600)
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 <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c

index ca71ef29cdbc89aec37d5916efc2c48a6e86c120..f5b6d303bf955b19a6e272eab8c9968652c54cf5 100644 (file)
--- 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