diff --git a/qemu/exec.c b/qemu/exec.c index 5e2e4102..d59b4641 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -1192,7 +1192,6 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size, error_propagate(errp, local_err); return NULL; } - mr->ram_block = new_block; return new_block; } diff --git a/qemu/memory.c b/qemu/memory.c index 91fcd039..24414d72 100644 --- a/qemu/memory.c +++ b/qemu/memory.c @@ -1174,6 +1174,7 @@ void memory_region_init_ram(struct uc_struct *uc, MemoryRegion *mr, mr->terminates = true; mr->destructor = memory_region_destructor_ram; ram_block = qemu_ram_alloc(size, mr, errp); + mr->ram_block = ram_block; mr->ram_addr = ram_block->offset; mr->dirty_log_mask = tcg_enabled(uc) ? (1 << DIRTY_MEMORY_CODE) : 0; } @@ -1194,6 +1195,7 @@ void memory_region_init_ram_ptr(struct uc_struct *uc, MemoryRegion *mr, /* qemu_ram_alloc_from_ptr cannot fail with ptr != NULL. */ assert(ptr != NULL); ram_block = qemu_ram_alloc_from_ptr(size, ptr, mr, &error_abort); + mr->ram_block = ram_block; mr->ram_addr = ram_block->offset; } @@ -1215,6 +1217,7 @@ void memory_region_init_resizeable_ram(struct uc_struct *uc, mr->terminates = true; mr->destructor = memory_region_destructor_ram; ram_block = qemu_ram_alloc_resizeable(size, max_size, resized, mr, errp); + mr->ram_block = ram_block; mr->ram_addr = ram_block->offset; mr->dirty_log_mask = tcg_enabled(uc) ? (1 << DIRTY_MEMORY_CODE) : 0; }