From 03404d652c997dc3a183ff8661016ca120cb35f6 Mon Sep 17 00:00:00 2001 From: Eric Brower Date: Mon, 26 Jul 2010 22:51:23 -0700 Subject: [PATCH] check for unconfigured cgroup in cgroup_find_parent Check for cgroup without controllers to prevent segfault, as the current implementation depends upon a controller being configured. Signed-off-by: Eric Brower Signed-off-by: Dhaval Giani --- src/api.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/api.c b/src/api.c index 5092ac96..33c64ccb 100644 --- a/src/api.c +++ b/src/api.c @@ -1502,6 +1502,12 @@ static int cgroup_find_parent(struct cgroup *cgroup, char **parent) *parent = NULL; + /* if cgroup has no controllers attached, consider it unconfigured */ + if (cgroup->controller[0] == NULL) { + cgroup_dbg("cgroup_find_parent called on unconfigured group\n"); + return ECGFAIL; + } + pthread_rwlock_rdlock(&cg_mount_table_lock); controller = cgroup->controller[0]->name; if (!cg_build_path_locked(cgroup->name, child_path, controller)) { -- 2.47.2