summaryrefslogtreecommitdiffstats
path: root/hw/timer
diff options
context:
space:
mode:
authorPan Nengyuan2020-02-07 15:04:28 +0100
committerPeter Maydell2020-02-07 15:04:28 +0100
commitf3a508eb4e5b486f0d6e8a16dbd8ff4b9dafcd72 (patch)
tree6301fec2f80d275c38bd568f4ad2af1c0aeacc2d /hw/timer
parentdocs/arm-cpu-features: Make kvm-no-adjvtime comment clearer (diff)
downloadqemu-f3a508eb4e5b486f0d6e8a16dbd8ff4b9dafcd72.tar.gz
qemu-f3a508eb4e5b486f0d6e8a16dbd8ff4b9dafcd72.tar.xz
qemu-f3a508eb4e5b486f0d6e8a16dbd8ff4b9dafcd72.zip
armv7m_systick: delay timer_new to avoid memleaks
There is a memory leak when we call 'device_list_properties' with typename = armv7m_systick. It's easy to reproduce as follow: virsh qemu-monitor-command vm1 --pretty '{"execute": "device-list-properties", "arguments": {"typename": "armv7m_systick"}}' This patch delay timer_new to fix this memleaks. Reported-by: Euler Robot <euler.robot@huawei.com> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com> Message-id: 20200205070659.22488-2-pannengyuan@huawei.com Cc: qemu-arm@nongnu.org Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/timer')
-rw-r--r--hw/timer/armv7m_systick.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/hw/timer/armv7m_systick.c b/hw/timer/armv7m_systick.c
index 85d122dbcb..74c58bcf24 100644
--- a/hw/timer/armv7m_systick.c
+++ b/hw/timer/armv7m_systick.c
@@ -216,6 +216,11 @@ static void systick_instance_init(Object *obj)
memory_region_init_io(&s->iomem, obj, &systick_ops, s, "systick", 0xe0);
sysbus_init_mmio(sbd, &s->iomem);
sysbus_init_irq(sbd, &s->irq);
+}
+
+static void systick_realize(DeviceState *dev, Error **errp)
+{
+ SysTickState *s = SYSTICK(dev);
s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, systick_timer_tick, s);
}
@@ -238,6 +243,7 @@ static void systick_class_init(ObjectClass *klass, void *data)
dc->vmsd = &vmstate_systick;
dc->reset = systick_reset;
+ dc->realize = systick_realize;
}
static const TypeInfo armv7m_systick_info = {