aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-08-22 13:55:52 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2012-08-22 10:47:14 -0500
commit4144f122b477164cf466ca69be24cf4ef5c218d3 (patch)
treea7f93d86ed886f5f7ba654eae2f20ad7e68b8f75
parent0ec64507a5e6366e6d8070a82c866b935f687ed9 (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>
-rw-r--r--qemu-ga.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/qemu-ga.c b/qemu-ga.c
index 8f87621ae4..26671fee3f 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -247,6 +247,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;
}