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 <[email protected]>
---
 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;
 }
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to