]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qemu-ga: don't leak a file descriptor upon failed lockf
authorJim Meyering <meyering@redhat.com>
Wed, 22 Aug 2012 11:55:52 +0000 (13:55 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 28 Aug 2012 06:50:02 +0000 (01:50 -0500)
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>
qemu-ga.c

index 8199da789cab6445b4a0e59b1378372638fba680..e7f9edbc705833cb9ca6d9894d19de8f00bda092 100644 (file)
--- 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;
     }