Skip to content

Commit

Permalink
Merge pull request #317 from sheabot/bugfix/free-memory_cgroup_file_path
Browse files Browse the repository at this point in the history
fix: cgroup: Free memory_cgroup_file_path if open fails
  • Loading branch information
rhatdan authored Jan 13, 2022
2 parents 8b2f604 + 830e644 commit 283294c
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit 283294c

Please sign in to comment.