mmap-alloc: fix error handling
Existing callers are checking for MAP_FAILED,
so we should return that on error.
Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
index 1394269..c37acbe 100644
--- a/util/mmap-alloc.c
+++ b/util/mmap-alloc.c
@@ -26,7 +26,7 @@
void *ptr1;
if (ptr == MAP_FAILED) {
- return NULL;
+ return MAP_FAILED;
}
/* Make sure align is a power of 2 */
@@ -41,7 +41,7 @@
fd, 0);
if (ptr1 == MAP_FAILED) {
munmap(ptr, total);
- return NULL;
+ return MAP_FAILED;
}
ptr += offset;