From: Eric Brower Date: Tue, 27 Jul 2010 05:51:23 +0000 (-0700) Subject: check for unconfigured cgroup in cgroup_find_parent X-Git-Tag: v0.37.1~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03404d652c997dc3a183ff8661016ca120cb35f6;p=thirdparty%2Flibcgroup.git 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 --- 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)) {