aboutsummaryrefslogtreecommitdiff
path: root/exec.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-01-21 16:18:35 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2015-01-26 12:27:05 +0100
commita904c91196a9c5dbd7b9abcd3d40b0824286fb1c (patch)
treef030234faba54dd872efc38f4d2671d142f661ef /exec.c
parentdd858343a73c5c47019c6ade282a91681e0d7105 (diff)
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. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/exec.c b/exec.c
index 410371d7b8..6b79ad1d11 100644
--- a/exec.c
+++ b/exec.c
@@ -1386,12 +1386,13 @@ static ram_addr_t ram_block_add(RAMBlock *new_block, Error **errp)
cpu_physical_memory_set_dirty_range(new_block->offset,
new_block->used_length);
- 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 (kvm_enabled()) {
- kvm_setup_guest_memory(new_block->host, new_block->max_length);
+ if (new_block->host) {
+ 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 (kvm_enabled()) {
+ kvm_setup_guest_memory(new_block->host, new_block->max_length);
+ }
}
return new_block->offset;