The GICv5 allocates memory and creates hashtables during realize and as part of its operation. Free those resources in finalize.
Since the GICv5 is created at QEMU startup and remains in existence for the lifetime of the process, this isn't an in-practice leak, only a theoretical one. Signed-off-by: Peter Maydell <[email protected]> --- hw/intc/arm_gicv5.c | 11 +++++++++++ hw/intc/arm_gicv5_common.c | 3 +++ 2 files changed, 14 insertions(+) diff --git a/hw/intc/arm_gicv5.c b/hw/intc/arm_gicv5.c index 8ffb2a49020..de0044df9c6 100644 --- a/hw/intc/arm_gicv5.c +++ b/hw/intc/arm_gicv5.c @@ -1970,6 +1970,17 @@ static void gicv5_init(Object *obj) static void gicv5_finalize(Object *obj) { + GICv5 *s = ARM_GICV5(obj); + + for (int i = 0; i < NUM_GICV5_DOMAINS; i++) { + GHashTable *ht = s->phys_lpi_config[i].lpi_cache; + + if (ht) { + g_hash_table_destroy(ht); + } + + g_free(s->hppi[i]); + } } static void gicv5_class_init(ObjectClass *oc, const void *data) diff --git a/hw/intc/arm_gicv5_common.c b/hw/intc/arm_gicv5_common.c index b155486af65..cc67246686e 100644 --- a/hw/intc/arm_gicv5_common.c +++ b/hw/intc/arm_gicv5_common.c @@ -112,6 +112,9 @@ static void gicv5_common_init(Object *obj) static void gicv5_common_finalize(Object *obj) { + GICv5Common *cs = ARM_GICV5_COMMON(obj); + + g_free(cs->spi); } static void gicv5_common_realize(DeviceState *dev, Error **errp) -- 2.43.0
