Skip to content

Commit

Permalink
plugins: Fix two resource leaks in setup_socket()
Browse files Browse the repository at this point in the history
Either accept() fails or exits normally, we need to close the fd.

Reported-by: Euler Robot <[email protected]>
Signed-off-by: Alex Chen <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
Message-Id: <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
Alex Chen authored and stsquad committed Nov 16, 2020
1 parent dbb864b commit 9cd7dde
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contrib/plugins/lockstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,13 @@ static bool setup_socket(const char *path)
socket_fd = accept(fd, NULL, NULL);
if (socket_fd < 0 && errno != EINTR) {
perror("accept socket");
close(fd);
return false;
}

qemu_plugin_outs("setup_socket::ready\n");

close(fd);
return true;
}

Expand Down

0 comments on commit 9cd7dde

Please sign in to comment.