mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-11 16:00:50 -07:00
hw/intc/loongson_ipi: Fix resource leak
Once initialised, QOM objects can be realized and unrealized multiple times before being finalized. Resources allocated in REALIZE must be deallocated in an equivalent UNREALIZE handler. Free the CPU array in loongson_ipi_unrealize() instead of loongson_ipi_finalize(). Cc: qemu-stable@nongnu.org Fixes:5e90b8db38("hw/loongarch: Set iocsr address space per-board rather than percpu") Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Song Gao <gaosong@loongson.cn> Message-Id: <20240723111405.14208-3-philmd@linaro.org> (cherry picked from commit0c2086bc73) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> (Mjt: rename loongson back to longarch for 9.0 due to lack of v9.0.0-582-gb4a12dfc2132 "hw/intc/loongarch_ipi: Rename as loongson_ipi")
This commit is contained in:
parent
437c556037
commit
9d0076b4a1
1 changed files with 8 additions and 8 deletions
|
|
@ -301,6 +301,13 @@ static void loongarch_ipi_realize(DeviceState *dev, Error **errp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void loongarch_ipi_unrealize(DeviceState *dev)
|
||||||
|
{
|
||||||
|
LoongArchIPI *s = LOONGARCH_IPI(dev);
|
||||||
|
|
||||||
|
g_free(s->cpu);
|
||||||
|
}
|
||||||
|
|
||||||
static const VMStateDescription vmstate_ipi_core = {
|
static const VMStateDescription vmstate_ipi_core = {
|
||||||
.name = "ipi-single",
|
.name = "ipi-single",
|
||||||
.version_id = 2,
|
.version_id = 2,
|
||||||
|
|
@ -336,23 +343,16 @@ static void loongarch_ipi_class_init(ObjectClass *klass, void *data)
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
|
||||||
dc->realize = loongarch_ipi_realize;
|
dc->realize = loongarch_ipi_realize;
|
||||||
|
dc->unrealize = loongarch_ipi_unrealize;
|
||||||
device_class_set_props(dc, ipi_properties);
|
device_class_set_props(dc, ipi_properties);
|
||||||
dc->vmsd = &vmstate_loongarch_ipi;
|
dc->vmsd = &vmstate_loongarch_ipi;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loongarch_ipi_finalize(Object *obj)
|
|
||||||
{
|
|
||||||
LoongArchIPI *s = LOONGARCH_IPI(obj);
|
|
||||||
|
|
||||||
g_free(s->cpu);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const TypeInfo loongarch_ipi_info = {
|
static const TypeInfo loongarch_ipi_info = {
|
||||||
.name = TYPE_LOONGARCH_IPI,
|
.name = TYPE_LOONGARCH_IPI,
|
||||||
.parent = TYPE_SYS_BUS_DEVICE,
|
.parent = TYPE_SYS_BUS_DEVICE,
|
||||||
.instance_size = sizeof(LoongArchIPI),
|
.instance_size = sizeof(LoongArchIPI),
|
||||||
.class_init = loongarch_ipi_class_init,
|
.class_init = loongarch_ipi_class_init,
|
||||||
.instance_finalize = loongarch_ipi_finalize,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void loongarch_ipi_register_types(void)
|
static void loongarch_ipi_register_types(void)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue