From: Cyrill Gorcunov <gorcunov@openvz.org>
To: Pekka Enberg <penberg@kernel.org>
Cc: Sasha Levin <levinsasha928@gmail.com>,
Asias He <asias.hejun@gmail.com>, Ingo Molnar <mingo@elte.hu>,
KVM-ML <kvm@vger.kernel.org>
Subject: [PATCH] kvm tools: Fix test for mmap failure
Date: Fri, 3 Feb 2012 23:15:41 +0400 [thread overview]
Message-ID: <20120203191541.GO11834@moon> (raw)
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 | 5 +++--
1 file changed, 3 insertions(+), 2 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
@@ -209,7 +209,7 @@ static void *setup_shmem(const char *key
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");
return mem;
@@ -259,8 +259,9 @@ int pci_shmem__init(struct kvm *kvm)
/* Open shared memory and plug it into the guest */
mem = setup_shmem(shmem_region->handle, shmem_region->size,
shmem_region->create);
- if (mem == NULL)
+ if (mem == MAP_FAILED)
return 0;
+
kvm__register_mem(kvm, shmem_region->phys_addr, shmem_region->size,
mem);
return 1;
next reply other threads:[~2012-02-03 19:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-03 19:15 Cyrill Gorcunov [this message]
2012-02-03 19:37 ` [PATCH] kvm tools: Fix test for mmap failure Cyrill Gorcunov
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=20120203191541.GO11834@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