aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2011-11-11 10:40:09 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2011-11-11 12:49:52 -0600
commit1bbd1592c89a433e1a0501d582652d54d367ca53 (patch)
tree693e60b3fd615b9b3a5ac22f168e362129d775d5
parent095ed5be7b61b7168020f0b807c9789b277a3956 (diff)
os-posix: Plug fd leak in qemu_create_pidfile()
Spotted by Coverity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--os-posix.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/os-posix.c b/os-posix.c
index dbf3b240f7..dc4a6bb3ff 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -372,13 +372,16 @@ int qemu_create_pidfile(const char *filename)
return -1;
}
if (lockf(fd, F_TLOCK, 0) == -1) {
+ close(fd);
return -1;
}
len = snprintf(buffer, sizeof(buffer), FMT_pid "\n", getpid());
if (write(fd, buffer, len) != len) {
+ close(fd);
return -1;
}
+ close(fd);
return 0;
}