mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-08-23 22:46:05 +00:00
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:
committed by
Will Deacon
parent
20b2b25a18
commit
5ecfffcc52
+4
-3
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user