From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: [Qemu-trivial] [PATCH 5/5] os-posix: Plug fd leak in qemu_create_pidfile()
Date: Fri, 11 Nov 2011 10:40:09 +0100 [thread overview]
Message-ID: <1321004409-3274-6-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1321004409-3274-1-git-send-email-armbru@redhat.com>
Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
os-posix.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/os-posix.c b/os-posix.c
index dbf3b24..dc4a6bb 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;
}
--
1.7.6.4
next prev parent reply other threads:[~2011-11-11 9:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-11 9:40 [Qemu-trivial] [PATCH 0/5] Plug a few trivial resource leaks Markus Armbruster
2011-11-11 9:40 ` [Qemu-trivial] [PATCH 1/5] qemu-char: Plug memory leak on qemu_chr_open_pty() error path Markus Armbruster
2011-11-11 9:40 ` [Qemu-trivial] [PATCH 2/5] ui: Plug memory leaks on parse_keyboard_layout() " Markus Armbruster
2011-11-11 9:40 ` [Qemu-trivial] [PATCH 3/5] qemu-sockets: Plug fd leak on unix_connect_opts() " Markus Armbruster
2011-11-11 9:40 ` [Qemu-trivial] [PATCH 4/5] posix-aio-compat: Plug memory leak on paio_init() " Markus Armbruster
2011-11-11 9:40 ` Markus Armbruster [this message]
2011-11-11 19:46 ` [Qemu-trivial] [Qemu-devel] [PATCH 0/5] Plug a few trivial resource leaks Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1321004409-3274-6-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).