exec: fix madvise of NULL pointer

Coverity flags this as "dereference after null check".  Not quite a
dereference, since it will just EFAULT, but still nice to fix.

Backports commit a904c91196a9c5dbd7b9abcd3d40b0824286fb1c from qemu
This commit is contained in:
Paolo Bonzini 2018-02-18 18:19:15 -05:00 committed by Lioncash
parent e07cd2542c
commit 15b3a9358e
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -1113,9 +1113,15 @@ static ram_addr_t ram_block_add(struct uc_struct *uc, RAMBlock *new_block, Error
new_block->used_length,
DIRTY_CLIENTS_ALL);
qemu_ram_setup_dump(new_block->host, new_block->max_length);
//qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_HUGEPAGE);
//qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_DONTFORK);
if (new_block->host) {
qemu_ram_setup_dump(new_block->host, new_block->max_length);
// Unicorn: commented out
//qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_HUGEPAGE);
//qemu_madvise(new_block->host, new_block->max_length, QEMU_MADV_DONTFORK);
//if (kvm_enabled()) {
// kvm_setup_guest_memory(new_block->host, new_block->max_length);
//}
}
return new_block->offset;
}