mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
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>
This commit is contained in:
+2
-2
@@ -26,7 +26,7 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared)
|
||||
void *ptr1;
|
||||
|
||||
if (ptr == MAP_FAILED) {
|
||||
return NULL;
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
/* Make sure align is a power of 2 */
|
||||
@@ -41,7 +41,7 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared)
|
||||
fd, 0);
|
||||
if (ptr1 == MAP_FAILED) {
|
||||
munmap(ptr, total);
|
||||
return NULL;
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
ptr += offset;
|
||||
|
||||
Reference in New Issue
Block a user