mips-cpu is not hotpluggable but its instance can still be created and finalized 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> --- target/mips/cpu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 1f6c41fd3401e88637c2c0d8fe3fcf4a38370288..e166b570984a40fba2ef417799a267eac9bff7d3 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -457,6 +457,13 @@ static void mips_cpu_realizefn(DeviceState *dev, Error **errp) MIPSCPUClass *mcc = MIPS_CPU_GET_CLASS(dev); Error *local_err = NULL; +#ifndef CONFIG_USER_ONLY + if (mcc->cpu_def->lcsr_cpucfg2 & (1 << CPUCFG2_LCSRP)) { + address_space_init(&env->iocsr.as, + &env->iocsr.mr, "IOCSR"); + } +#endif + if (!clock_get(cpu->clock)) { #ifndef CONFIG_USER_ONLY if (!qtest_enabled()) { @@ -505,8 +512,6 @@ static void mips_cpu_initfn(Object *obj) if (mcc->cpu_def->lcsr_cpucfg2 & (1 << CPUCFG2_LCSRP)) { memory_region_init_io(&env->iocsr.mr, OBJECT(cpu), NULL, env, "iocsr", UINT64_MAX); - address_space_init(&env->iocsr.as, - &env->iocsr.mr, "IOCSR"); } #endif } -- 2.51.0