The wdog_timer allocated in instance_init is causing ASAN to report a
leak when the object is destroyed (e.g. during qom-test and
device-introspect-test).
Add an instance_finalize handler to free it.
Fixes: 21fcfb604608 ("hw/misc/bcm2835_powermgt: implement a real watchdog
timer")
Signed-off-by: Marc-André Lureau <[email protected]>
---
hw/misc/bcm2835_powermgt.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/hw/misc/bcm2835_powermgt.c b/hw/misc/bcm2835_powermgt.c
index 7b01be48bb7f..1de5a55a4f5b 100644
--- a/hw/misc/bcm2835_powermgt.c
+++ b/hw/misc/bcm2835_powermgt.c
@@ -152,6 +152,13 @@ static void bcm2835_powermgt_init(Object *obj)
bcm2835_powermgt_expire, s);
}
+static void bcm2835_powermgt_finalize(Object *obj)
+{
+ BCM2835PowerMgtState *s = BCM2835_POWERMGT(obj);
+
+ timer_free(s->wdog_timer);
+}
+
static void bcm2835_powermgt_reset(DeviceState *dev)
{
BCM2835PowerMgtState *s = BCM2835_POWERMGT(dev);
@@ -177,6 +184,7 @@ static const TypeInfo bcm2835_powermgt_info = {
.instance_size = sizeof(BCM2835PowerMgtState),
.class_init = bcm2835_powermgt_class_init,
.instance_init = bcm2835_powermgt_init,
+ .instance_finalize = bcm2835_powermgt_finalize,
};
static void bcm2835_powermgt_register_types(void)
--
2.55.0.543.g5ebe2ebe4ea8