From: Markus Armbruster Date: Fri, 11 Nov 2011 09:40:09 +0000 (+0100) Subject: os-posix: Plug fd leak in qemu_create_pidfile() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=1bbd1592;p=qemu.git os-posix: Plug fd leak in qemu_create_pidfile() Spotted by Coverity. Signed-off-by: Markus Armbruster Signed-off-by: Anthony Liguori --- 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; }