sun4u-iommu is not hotpluggable but its instance can still be created and destroyed when processing the device-list-properties QMP command. Exposing such a temporary instance to AddressSpace should be avoided because it leaks the instance.
Expose instances to the AddressSpace at their realization time so that it won't happen for the temporary instances. Signed-off-by: Akihiko Odaki <od...@rsg.ci.i.u-tokyo.ac.jp> --- hw/sparc64/sun4u_iommu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/sparc64/sun4u_iommu.c b/hw/sparc64/sun4u_iommu.c index 14645f475a09ed3a6bef77f8d8b4b6b4b36ae40a..b6568551935610116d33481ae8d9fc08f02ecf7b 100644 --- a/hw/sparc64/sun4u_iommu.c +++ b/hw/sparc64/sun4u_iommu.c @@ -298,18 +298,25 @@ static void iommu_init(Object *obj) memory_region_init_iommu(&s->iommu, sizeof(s->iommu), TYPE_SUN4U_IOMMU_MEMORY_REGION, OBJECT(s), "iommu-sun4u", UINT64_MAX); - address_space_init(&s->iommu_as, MEMORY_REGION(&s->iommu), "iommu-as"); memory_region_init_io(&s->iomem, obj, &iommu_mem_ops, s, "iommu", IOMMU_NREGS * sizeof(uint64_t)); sysbus_init_mmio(sbd, &s->iomem); } +static void iommu_realize(DeviceState *dev, Error **errp) +{ + IOMMUState *s = SUN4U_IOMMU(dev); + + address_space_init(&s->iommu_as, MEMORY_REGION(&s->iommu), "iommu-as"); +} + static void iommu_class_init(ObjectClass *klass, const void *data) { DeviceClass *dc = DEVICE_CLASS(klass); device_class_set_legacy_reset(dc, iommu_reset); + dc->realize = iommu_realize; } static const TypeInfo iommu_info = { -- 2.51.0