Skip to content

Commit

Permalink
coverity: #1438233
Browse files Browse the repository at this point in the history
Resource leak

Signed-off-by: 2xsec <dh48.jeong@samsung.com>
  • Loading branch information
2xsec committed Aug 6, 2018
1 parent d97c3a3 commit 90a170d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lxc/pam/pam_cgfs.c
Expand Up @@ -1295,6 +1295,7 @@ static bool cgv2_init(uid_t uid, gid_t gid)
*/
goto cleanup;
}

cg_systemd_prune_init_scope(init_cgroup);

/* Check if the v2 hierarchy is mounted at its standard location.
Expand Down Expand Up @@ -1329,6 +1330,7 @@ static bool cgv2_init(uid_t uid, gid_t gid)
while (getline(&line, &len, f) != -1) {
char *user_slice;
bool has_user_slice = false;

if (!is_cgv2(line))
continue;

Expand All @@ -1342,6 +1344,7 @@ static bool cgv2_init(uid_t uid, gid_t gid)
free(user_slice);

cgv2_add_controller(NULL, mountpoint, current_cgroup, init_cgroup, has_user_slice);

/* Although the unified hierarchy can be mounted multiple times,
* each of those mountpoints will expose identical information.
* So let the first mountpoint we find, win.
Expand All @@ -1359,8 +1362,10 @@ static bool cgv2_init(uid_t uid, gid_t gid)
fclose(f);
free(line);

if (!ret)
if (!ret) {
free(init_cgroup);
free(current_cgroup);
}

return ret;
}
Expand Down

0 comments on commit 90a170d

Please sign in to comment.