mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
stellaris: delay timer_new to avoid memleaks
There is a memory leak when we call 'device_list_properties' with typename = stellaris-gptm. It's easy to reproduce as follow: virsh qemu-monitor-command vm1 --pretty '{"execute": "device-list-properties", "arguments": {"typename": "stellaris-gptm"}}' This patch delay timer_new in realize to fix it. Reported-by: Euler Robot <euler.robot@huawei.com> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20200205070659.22488-4-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>
This commit is contained in:
parent
53b95da160
commit
af6c91b490
1 changed files with 6 additions and 1 deletions
|
@ -347,11 +347,15 @@ static void stellaris_gptm_init(Object *obj)
|
||||||
sysbus_init_mmio(sbd, &s->iomem);
|
sysbus_init_mmio(sbd, &s->iomem);
|
||||||
|
|
||||||
s->opaque[0] = s->opaque[1] = s;
|
s->opaque[0] = s->opaque[1] = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void stellaris_gptm_realize(DeviceState *dev, Error **errp)
|
||||||
|
{
|
||||||
|
gptm_state *s = STELLARIS_GPTM(dev);
|
||||||
s->timer[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[0]);
|
s->timer[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[0]);
|
||||||
s->timer[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[1]);
|
s->timer[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* System controller. */
|
/* System controller. */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1536,6 +1540,7 @@ static void stellaris_gptm_class_init(ObjectClass *klass, void *data)
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
|
||||||
dc->vmsd = &vmstate_stellaris_gptm;
|
dc->vmsd = &vmstate_stellaris_gptm;
|
||||||
|
dc->realize = stellaris_gptm_realize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo stellaris_gptm_info = {
|
static const TypeInfo stellaris_gptm_info = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue