[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 47/48] stm32f2xx_timer: delay timer_new to avoid memleaks
From: |
Peter Maydell |
Subject: |
[PULL 47/48] stm32f2xx_timer: delay timer_new to avoid memleaks |
Date: |
Fri, 7 Feb 2020 14:33:42 +0000 |
From: Pan Nengyuan <address@hidden>
There is a memory leak when we call 'device_list_properties' with typename =
stm32f2xx_timer. It's easy to reproduce as follow:
virsh qemu-monitor-command vm1 --pretty '{"execute":
"device-list-properties", "arguments": {"typename": "stm32f2xx_timer"}}'
This patch delay timer_new to fix this memleaks.
Reported-by: Euler Robot <address@hidden>
Signed-off-by: Pan Nengyuan <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Alistair Francis <address@hidden>
Message-id: address@hidden
Cc: Alistair Francis <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
---
hw/timer/stm32f2xx_timer.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/timer/stm32f2xx_timer.c b/hw/timer/stm32f2xx_timer.c
index fb370ce0f05..06ec8a02c25 100644
--- a/hw/timer/stm32f2xx_timer.c
+++ b/hw/timer/stm32f2xx_timer.c
@@ -314,7 +314,11 @@ static void stm32f2xx_timer_init(Object *obj)
memory_region_init_io(&s->iomem, obj, &stm32f2xx_timer_ops, s,
"stm32f2xx_timer", 0x400);
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
+}
+static void stm32f2xx_timer_realize(DeviceState *dev, Error **errp)
+{
+ STM32F2XXTimerState *s = STM32F2XXTIMER(dev);
s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, stm32f2xx_timer_interrupt, s);
}
@@ -325,6 +329,7 @@ static void stm32f2xx_timer_class_init(ObjectClass *klass,
void *data)
dc->reset = stm32f2xx_timer_reset;
device_class_set_props(dc, stm32f2xx_timer_properties);
dc->vmsd = &vmstate_stm32f2xx_timer;
+ dc->realize = stm32f2xx_timer_realize;
}
static const TypeInfo stm32f2xx_timer_info = {
--
2.20.1
- [PULL 38/48] target/arm: Enable ARMv8.1-VHE in -cpu max, (continued)
- [PULL 38/48] target/arm: Enable ARMv8.1-VHE in -cpu max, Peter Maydell, 2020/02/07
- [PULL 37/48] target/arm: Update arm_cpu_do_interrupt_aarch64 for VHE, Peter Maydell, 2020/02/07
- [PULL 40/48] target/arm: Pass more cpu state to arm_excp_unmasked, Peter Maydell, 2020/02/07
- [PULL 41/48] target/arm: Use bool for unmasked in arm_excp_unmasked, Peter Maydell, 2020/02/07
- [PULL 43/48] bcm2835_dma: Fix the ylen loop in TD mode, Peter Maydell, 2020/02/07
- [PULL 39/48] target/arm: Move arm_excp_unmasked to cpu.c, Peter Maydell, 2020/02/07
- [PULL 42/48] target/arm: Raise only one interrupt in arm_cpu_exec_interrupt, Peter Maydell, 2020/02/07
- [PULL 44/48] bcm2835_dma: Re-initialize xlen in TD mode, Peter Maydell, 2020/02/07
- [PULL 45/48] docs/arm-cpu-features: Make kvm-no-adjvtime comment clearer, Peter Maydell, 2020/02/07
- [PULL 46/48] armv7m_systick: delay timer_new to avoid memleaks, Peter Maydell, 2020/02/07
- [PULL 47/48] stm32f2xx_timer: delay timer_new to avoid memleaks,
Peter Maydell <=
- [PULL 48/48] stellaris: delay timer_new to avoid memleaks, Peter Maydell, 2020/02/07
- Re: [PULL 00/48] target-arm queue, Peter Maydell, 2020/02/10