]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: #1438233
author2xsec <dh48.jeong@samsung.com>
Mon, 6 Aug 2018 04:54:34 +0000 (13:54 +0900)
committer2xsec <dh48.jeong@samsung.com>
Mon, 6 Aug 2018 04:54:34 +0000 (13:54 +0900)
Resource leak

Signed-off-by: 2xsec <dh48.jeong@samsung.com>
src/lxc/pam/pam_cgfs.c

index 072c9a41fe4a9253894cc205265253cfe34aeee4..cb3286408a6099c79aa50b6379ba8539b8f9da7a 100644 (file)
@@ -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.
@@ -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;
 
@@ -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.
@@ -1359,8 +1362,10 @@ cleanup:
                fclose(f);
        free(line);
 
-       if (!ret)
+       if (!ret) {
+               free(init_cgroup);
                free(current_cgroup);
+       }
 
        return ret;
 }