From 830e6445cebd3158c8949bbc8fa7d16897891558 Mon Sep 17 00:00:00 2001 From: sheabot Date: Tue, 24 Aug 2021 13:59:13 -0600 Subject: [PATCH] fix: cgroup: Free memory_cgroup_file_path if open fails. Call g_free instead of free. --- src/cgroup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cgroup.c b/src/cgroup.c index 00efed79..48f611ae 100644 --- a/src/cgroup.c +++ b/src/cgroup.c @@ -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; } @@ -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; } @@ -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; }