[PATCH] kvm tools: Fix test for mmap failure

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

 



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

Signed-off-by: Cyrill Gorcunov <gorcunov@xxxxxxxxx>
---
 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;
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux