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>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
Cyrill Gorcunov
2012-02-03 23:37:00 +04:00
committed by Will Deacon
parent 20b2b25a18
commit 5ecfffcc52
+4 -3
View File
@@ -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;
}