qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] hw/char/exynos4210_uart: Fix memleaks in exynos4210_uart_ini


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] hw/char/exynos4210_uart: Fix memleaks in exynos4210_uart_init
Date: Wed, 12 Feb 2020 07:16:03 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 2/12/20 4:36 AM, address@hidden wrote:
From: Chen Qun <address@hidden>

It's easy to reproduce as follow:
virsh qemu-monitor-command vm1 --pretty '{"execute": "device-list-properties",
"arguments":{"typename":"exynos4210.uart"}}'

ASAN shows memory leak stack:
   #1 0xfffd896d71cb in g_malloc0 (/lib64/libglib-2.0.so.0+0x571cb)
   #2 0xaaad270beee3 in timer_new_full /qemu/include/qemu/timer.h:530
   #3 0xaaad270beee3 in timer_new /qemu/include/qemu/timer.h:551
   #4 0xaaad270beee3 in timer_new_ns /qemu/include/qemu/timer.h:569
   #5 0xaaad270beee3 in exynos4210_uart_init /qemu/hw/char/exynos4210_uart.c:677
   #6 0xaaad275c8f4f in object_initialize_with_type /qemu/qom/object.c:516
   #7 0xaaad275c91bb in object_new_with_type /qemu/qom/object.c:684
   #8 0xaaad2755df2f in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:152

Reported-by: Euler Robot <address@hidden>
Signed-off-by: Chen Qun <address@hidden>
---
  hw/char/exynos4210_uart.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c
index 25d6588e41..5048db5410 100644
--- a/hw/char/exynos4210_uart.c
+++ b/hw/char/exynos4210_uart.c
@@ -674,10 +674,6 @@ static void exynos4210_uart_init(Object *obj)
      SysBusDevice *dev = SYS_BUS_DEVICE(obj);
      Exynos4210UartState *s = EXYNOS4210_UART(dev);
- s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
-                                         exynos4210_uart_timeout_int, s);
-    s->wordtime = NANOSECONDS_PER_SECOND * 10 / 9600;

Why are you moving s->wordtime from init() to realize()?

-
      /* memory mapping */
      memory_region_init_io(&s->iomem, obj, &exynos4210_uart_ops, s,
                            "exynos4210.uart", EXYNOS4210_UART_REGS_MEM_SIZE);
@@ -691,6 +687,10 @@ static void exynos4210_uart_realize(DeviceState *dev, 
Error **errp)
  {
      Exynos4210UartState *s = EXYNOS4210_UART(dev);
+ s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
+                                         exynos4210_uart_timeout_int, s);
+    s->wordtime = NANOSECONDS_PER_SECOND * 10 / 9600;
+
      qemu_chr_fe_set_handlers(&s->chr, exynos4210_uart_can_receive,
                               exynos4210_uart_receive, exynos4210_uart_event,
                               NULL, s, NULL, true);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]