aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-08-22 13:55:52 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2012-08-28 01:50:02 -0500
commit1bc633246105b629b72728b007fd9d414c6038e8 (patch)
treeffc233a92e9c3a2f7e5ea2052a5e56ce96f5ef62
parent07548727b3ef25c63ed5a3f068f46059963490c6 (diff)
qemu-ga: don't leak a file descriptor upon failed lockf
Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> (cherry picked from commit 4144f122b477164cf466ca69be24cf4ef5c218d3) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--qemu-ga.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/qemu-ga.c b/qemu-ga.c
index 8199da789..e7f9edbc7 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -248,6 +248,9 @@ static bool ga_open_pidfile(const char *pidfile)
pidfd = open(pidfile, O_CREAT|O_WRONLY, S_IRUSR|S_IWUSR);
if (pidfd == -1 || lockf(pidfd, F_TLOCK, 0)) {
g_critical("Cannot lock pid file, %s", strerror(errno));
+ if (pidfd != -1) {
+ close(pidfd);
+ }
return false;
}