Companion to 2/3: remove definition of dir and parent_dir
Check for cgroup without controllers to prevent segfault.
Perhaps unnecessary as a safety check, so long as
cgroup_create_cgroup_from_parent
no longer calls this function. Alternatively, the check could redirect to
the new cgroup_get_parent_name() if no controllers exist.
diff --git a/src/api.c b/src/api.c
index 4823006..a29fe80 100644
--- a/src/api.c
+++ b/src/api.c
@@ -1443,11 +1498,16 @@ static int cgroup_find_parent(struct cgroup
*cgroup, char **parent)
char *parent_path = NULL;
struct stat stat_child, stat_parent;
char *controller = NULL;
- char *dir = NULL, *parent_dir = NULL;
int ret = 0;
*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)) {
--
E
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel