From c1106b811b4a2746789ef76e7db154dd18d001e8 Mon Sep 17 00:00:00 2001 From: lazymio Date: Tue, 16 Nov 2021 22:44:03 +0100 Subject: [PATCH] Fix a memory leak in mmio --- qemu/softmmu/memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qemu/softmmu/memory.c b/qemu/softmmu/memory.c index 96635a48..ccc93a49 100644 --- a/qemu/softmmu/memory.c +++ b/qemu/softmmu/memory.c @@ -82,6 +82,7 @@ typedef struct _mmio_cbs { void *user_data_read; uc_cb_mmio_write_t write; void *user_data_write; + MemoryRegionOps ops; } mmio_cbs; static uint64_t mmio_read_wrapper(struct uc_struct *uc, void *opaque, hwaddr addr, unsigned size) @@ -118,8 +119,8 @@ MemoryRegion *memory_map_io(struct uc_struct *uc, ram_addr_t begin, size_t size, void *user_data_read, void *user_data_write) { MemoryRegion *mmio = g_new(MemoryRegion, 1); - MemoryRegionOps *ops = g_new(MemoryRegionOps, 1); mmio_cbs* opaques = g_new(mmio_cbs, 1); + MemoryRegionOps *ops = &opaques->ops; opaques->read = read_cb; opaques->write = write_cb; opaques->user_data_read = user_data_read;