public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@openvz.org>
To: Pekka Enberg <penberg@kernel.org>,
	Sasha Levin <levinsasha928@gmail.com>,
	Asias He <asias.hejun@gmail.com>, Ingo Molnar <mingo@elte.hu>,
	KVM-ML <kvm@vger.kernel.org>
Subject: Re: [PATCH] kvm tools: Fix test for mmap failure
Date: Fri, 3 Feb 2012 23:37:00 +0400	[thread overview]
Message-ID: <20120203193700.GE3314@moon> (raw)
In-Reply-To: <20120203191541.GO11834@moon>

On Fri, Feb 03, 2012 at 11:15:41PM +0400, Cyrill Gorcunov wrote:
> On error mmap returns MAP_FAILED so we
> need a proper test here.
>

Pekka, pick this one instead -- a caller is expecting null/not-null
only.

	Cyrill
---
kvm tools: Fix test for mmap failure

On error mmap returns MAP_FAILED so we
need a proper test here.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 tools/kvm/hw/pci-shmem.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Index: linux-2.6.git/tools/kvm/hw/pci-shmem.c
===================================================================
--- linux-2.6.git.orig/tools/kvm/hw/pci-shmem.c
+++ linux-2.6.git/tools/kvm/hw/pci-shmem.c
@@ -207,10 +207,11 @@ static void *setup_shmem(const char *key
 	}
 	mem = mmap(NULL, len,
 		   PROT_READ | PROT_WRITE, MAP_SHARED | MAP_NORESERVE, fd, 0);
-	close(fd);
-
-	if (mem == NULL)
+	if (mem == MAP_FAILED) {
 		pr_warning("Failed to mmap shared memory file");
+		mem = NULL;
+	}
+	close(fd);
 
 	return mem;
 }

  reply	other threads:[~2012-02-03 19:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03 19:15 [PATCH] kvm tools: Fix test for mmap failure Cyrill Gorcunov
2012-02-03 19:37 ` Cyrill Gorcunov [this message]
2012-02-04  7:24   ` Pekka Enberg

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=20120203193700.GE3314@moon \
    --to=gorcunov@openvz.org \
    --cc=asias.hejun@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=mingo@elte.hu \
    --cc=penberg@kernel.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