summary refs log tree commit diff stats
path: root/hw/core/platform-bus.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@redhat.com>2020-02-22 18:11:51 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2020-03-17 15:18:48 +0100
commitde95af9967a777263894165e3ba576581a82da4e (patch)
tree1f1eeb852d2b5f0ebfa7582969e6b442efbb595f /hw/core/platform-bus.c
parent84969111e656eb594ac123a23aa120ff5e157ee4 (diff)
downloadfocaccia-qemu-de95af9967a777263894165e3ba576581a82da4e.tar.gz
focaccia-qemu-de95af9967a777263894165e3ba576581a82da4e.zip
hw/core: Let devices own the MemoryRegion they create
Avoid orphan memory regions being added in the /unattached QOM
container.

This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'hw/core/platform-bus.c')
-rw-r--r--hw/core/platform-bus.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c
index 22c5f76dd0..d494e5cec1 100644
--- a/hw/core/platform-bus.c
+++ b/hw/core/platform-bus.c
@@ -187,7 +187,8 @@ static void platform_bus_realize(DeviceState *dev, Error **errp)
     d = SYS_BUS_DEVICE(dev);
     pbus = PLATFORM_BUS_DEVICE(dev);
 
-    memory_region_init(&pbus->mmio, NULL, "platform bus", pbus->mmio_size);
+    memory_region_init(&pbus->mmio, OBJECT(dev), "platform bus",
+                       pbus->mmio_size);
     sysbus_init_mmio(d, &pbus->mmio);
 
     pbus->used_irqs = bitmap_new(pbus->num_irqs);