[tip:tools/kvm] kvm tools: Fix test for mmap failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  76b96f4f4f01128495c524b1b44940c28786196b
Gitweb:     http://git.kernel.org/tip/76b96f4f4f01128495c524b1b44940c28786196b
Author:     Cyrill Gorcunov <gorcunov@xxxxxxxxxx>
AuthorDate: Fri, 3 Feb 2012 23:37:00 +0400
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Sat, 4 Feb 2012 09:23:56 +0200

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@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/hw/pci-shmem.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/kvm/hw/pci-shmem.c b/tools/kvm/hw/pci-shmem.c
index 8bac151..ac2d264 100644
--- a/tools/kvm/hw/pci-shmem.c
+++ b/tools/kvm/hw/pci-shmem.c
@@ -207,10 +207,11 @@ static void *setup_shmem(const char *key, size_t len, int creating)
 	}
 	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;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux