return false;
f = fopen("/proc/self/mountinfo", "r");
- if (!f)
+ if (!f) {
+ free(basecginfo);
return false;
+ }
cgv1_get_controllers(&klist, &nlist);
char **controller_list = NULL;
char *mountpoint, *base_cgroup;
- if (!is_lxcfs(line) && !is_cgv1(line))
+ if (is_lxcfs(line) || !is_cgv1(line))
continue;
controller_list = cgv1_get_proc_mountinfo_controllers(klist, nlist, line);
for (it = cgv1_hierarchies; it && *it; it++) {
if ((*it)->controllers) {
char *init_cgroup, *user_slice;
+ /* We've already stored the controller and received its
+ * current cgroup. If we now fail to retrieve its init
+ * cgroup, we should probably fail.
+ */
init_cgroup = cgv1_get_current_cgroup(basecginfo, (*it)->controllers[0]);
+ if (!init_cgroup) {
+ free(basecginfo);
+ return false;
+ }
cg_systemd_prune_init_scope(init_cgroup);
(*it)->init_cgroup = init_cgroup;
lxcfs_debug("cgroupfs v1 controller \"%s\" has init "
struct cgv1_hierarchy **it;
for (it = cgv1_hierarchies; it && *it; it++) {
- char *path;
char **controller;
bool entered = false;
for (controller = (*it)->controllers; controller && *controller;
controller++) {
+ char *path;
if ((*it)->systemd_user_slice)
continue;
}
lxcfs_debug("Attempting to enter cgroupfs v1 hierarchy in \"%s\" cgroup.\n", path);
entered = write_int(path, (int)getpid());
- free(path);
- if (entered)
+ if (entered) {
+ free(path);
break;
+ }
lxcfs_debug("Failed to enter cgroupfs v1 hierarchy in \"%s\" cgroup.\n", path);
+ free(path);
}
if (!entered)
return false;