Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cgroup: Free memory_cgroup_file_path if open fails #317

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ static void setup_oom_handling_cgroup_v1(int pid)
_cleanup_close_ int cfd = open(memory_cgroup_file_path, O_WRONLY | O_CLOEXEC);
if (cfd == -1) {
nwarnf("Failed to open %s", memory_cgroup_file_path);
g_free(memory_cgroup_file_path);
return;
}

Expand Down Expand Up @@ -197,7 +198,7 @@ static gboolean oom_cb_cgroup_v1(int fd, GIOCondition condition, gpointer user_d
/* End of input */
close(fd);
oom_event_fd = -1;
free(cgroup_event_control_path);
g_free(cgroup_event_control_path);
return G_SOURCE_REMOVE;
}

Expand Down Expand Up @@ -226,7 +227,7 @@ static gboolean oom_cb_cgroup_v1(int fd, GIOCondition condition, gpointer user_d
if (num_read == 0) {
close(fd);
oom_event_fd = -1;
free(cgroup_event_control_path);
g_free(cgroup_event_control_path);
return G_SOURCE_REMOVE;
}

Expand Down