[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 3/6] hw/arm/spitz: move timer_new from init() into realize() t
From: |
Pan Nengyuan |
Subject: |
[PATCH v3 3/6] hw/arm/spitz: move timer_new from init() into realize() to avoid memleaks |
Date: |
Thu, 27 Feb 2020 10:50:52 +0800 |
There are some memleaks when we call 'device_list_properties'. This patch move
timer_new from init into realize to fix it.
Reported-by: Euler Robot <address@hidden>
Signed-off-by: Pan Nengyuan <address@hidden>
---
Cc: Andrzej Zaborowski <address@hidden>
---
hw/arm/spitz.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index e001088103..cbfa6934cf 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -524,11 +524,16 @@ static void spitz_keyboard_init(Object *obj)
spitz_keyboard_pre_map(s);
- s->kbdtimer = timer_new_ns(QEMU_CLOCK_VIRTUAL, spitz_keyboard_tick, s);
qdev_init_gpio_in(dev, spitz_keyboard_strobe, SPITZ_KEY_STROBE_NUM);
qdev_init_gpio_out(dev, s->sense, SPITZ_KEY_SENSE_NUM);
}
+static void spitz_keyboard_realize(DeviceState *dev, Error **errp)
+{
+ SpitzKeyboardState *s = SPITZ_KEYBOARD(dev);
+ s->kbdtimer = timer_new_ns(QEMU_CLOCK_VIRTUAL, spitz_keyboard_tick, s);
+}
+
/* LCD backlight controller */
#define LCDTG_RESCTL 0x00
@@ -1115,6 +1120,7 @@ static void spitz_keyboard_class_init(ObjectClass *klass,
void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
dc->vmsd = &vmstate_spitz_kbd;
+ dc->realize = spitz_keyboard_realize;
}
static const TypeInfo spitz_keyboard_info = {
--
2.18.2
- [PATCH v3 0/6] delay timer_new from init to realize to fix memleaks., Pan Nengyuan, 2020/02/26
- [PATCH v3 3/6] hw/arm/spitz: move timer_new from init() into realize() to avoid memleaks,
Pan Nengyuan <=
- [PATCH v3 4/6] hw/arm/strongarm: move timer_new from init() into realize() to avoid memleaks, Pan Nengyuan, 2020/02/26
- [PATCH v3 2/6] hw/arm/pxa2xx: move timer_new from init() into realize() to avoid memleaks, Pan Nengyuan, 2020/02/26
- [PATCH v3 6/6] hw/timer/cadence_ttc: move timer_new from init() into realize() to avoid memleaks, Pan Nengyuan, 2020/02/26
- [PATCH v3 5/6] hw/misc/mos6522: move timer_new from init() into realize() to avoid memleaks, Pan Nengyuan, 2020/02/26
- [PATCH v3 1/6] s390x: fix memleaks in cpu_finalize, Pan Nengyuan, 2020/02/26