hw/arm/spitz: move timer_new from init() into realize() to avoid memleaks
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 <euler.robot@huawei.com> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com> Message-id: 20200227025055.14341-4-pannengyuan@huawei.com Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
1afaadb592
commit
5719f9745e
@ -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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user