Use memory_region_new_ram to avoid leaking memory region.
Signed-off-by: BALATON Zoltan <[email protected]>
---
hw/xtensa/xtfpga.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index ed24720f94..b8ae1994d8 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -161,9 +161,8 @@ static void xtfpga_net_init(MemoryRegion *address_space,
memory_region_add_subregion(address_space, descriptors,
sysbus_mmio_get_region(s, 1));
- ram = g_malloc(sizeof(*ram));
- memory_region_init_ram(ram, OBJECT(s), "open_eth.ram", 16 * KiB,
- &error_fatal);
+ ram = memory_region_new_ram(OBJECT(s), "open_eth.ram", 16 * KiB,
+ &error_fatal);
memory_region_add_subregion(address_space, buffers, ram);
}
--
2.41.3