Patchwork [5/8] qemu-ga: Plug file descriptor leak on ga_open_pidfile() error path

login
register
mail settings
Submitter Michael Roth
Date Jan. 14, 2013, 7:55 p.m.
Message ID <1358193312-15960-6-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/211887/
State New
Headers show

Comments

Michael Roth - Jan. 14, 2013, 7:55 p.m.
From: Markus Armbruster <armbru@redhat.com>

Spotted by Coverity.  Also document why we keep it open on success.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qga/main.c |    2 ++
 1 file changed, 2 insertions(+)

Patch

diff --git a/qga/main.c b/qga/main.c
index 96d3cfa..db281a5 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -299,10 +299,12 @@  static bool ga_open_pidfile(const char *pidfile)
         goto fail;
     }
 
+    /* keep pidfile open & locked forever */
     return true;
 
 fail:
     unlink(pidfile);
+    close(pidfd);
     return false;
 }
 #else /* _WIN32 */