From: Laszlo Ersek <lersek@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH] exec: fix error handling in file_ram_alloc
Date: Fri, 18 Mar 2016 08:54:23 +0100 [thread overview]
Message-ID: <56EBB42F.4050506@redhat.com> (raw)
In-Reply-To: <1458255068-11724-1-git-send-email-pbonzini@redhat.com>
On 03/17/16 23:51, Paolo Bonzini wrote:
> One instance of double closing, and invalid close(-1) in some cases
> of "goto error".
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> exec.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/exec.c b/exec.c
> index f398d21..5c16f41 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -1238,7 +1238,7 @@ static void *file_ram_alloc(RAMBlock *block,
> char *sanitized_name;
> char *c;
> void *area;
> - int fd;
> + int fd = -1;
> int64_t page_size;
>
> if (kvm_enabled() && !kvm_has_sync_mmu()) {
> @@ -1320,7 +1320,6 @@ static void *file_ram_alloc(RAMBlock *block,
> if (area == MAP_FAILED) {
> error_setg_errno(errp, errno,
> "unable to map backing store for guest RAM");
> - close(fd);
> goto error;
> }
>
> @@ -1335,7 +1334,9 @@ error:
> if (unlink_on_error) {
> unlink(path);
> }
> - close(fd);
> + if (fd != -1) {
> + close(fd);
> + }
> return NULL;
> }
> #endif
>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
prev parent reply other threads:[~2016-03-18 7:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-17 22:51 [Qemu-devel] [PATCH] exec: fix error handling in file_ram_alloc Paolo Bonzini
2016-03-18 7:54 ` Laszlo Ersek [this message]
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=56EBB42F.4050506@redhat.com \
--to=lersek@redhat.com \
--cc=armbru@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@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).