Skip to content

Commit

Permalink
Merge pull request #2216 from giuseppe/fix-fd-leak
Browse files Browse the repository at this point in the history
conmon: do not leak fd when creating oom file
Signed-off-by: Peter Hunt <pehunt@redhat.com>
  • Loading branch information
Mrunal Patel authored and haircommander committed Apr 10, 2019
1 parent 2402bf4 commit 9ac5d3f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion conmon/conmon.c
Expand Up @@ -881,10 +881,12 @@ static gboolean oom_cb(int fd, GIOCondition condition, G_GNUC_UNUSED gpointer us
}

if (num_read > 0) {
_cleanup_close_ int oom_fd = -1;
if (num_read != sizeof(uint64_t))
nwarn("Failed to read full oom event from eventfd");
ninfo("OOM received");
if (open("oom", O_CREAT, 0666) < 0) {
oom_fd = open("oom", O_CREAT, 0666);
if (oom_fd < 0) {
nwarn("Failed to write oom file");
}
return G_SOURCE_CONTINUE;
Expand Down

0 comments on commit 9ac5d3f

Please sign in to comment.