diff mbox

[17/29] hw/lm32/milkymist.c: Fix memory leak spotted by valgrind

Message ID 1432814932-12608-18-git-send-email-zhaoshenglong@huawei.com
State New
Headers show

Commit Message

Shannon Zhao May 28, 2015, 12:08 p.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

valgrind complains about:
==20652== 8 bytes in 1 blocks are definitely lost in loss record 252 of 1,314
==20652==    at 0x4C2845D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20652==    by 0x1E77E7: malloc_and_trace (vl.c:2556)
==20652==    by 0x64C770E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3600.3)
==20652==    by 0x238C43: qemu_extend_irqs (irq.c:55)
==20652==    by 0x238CCF: qemu_allocate_irqs (irq.c:64)
==20652==    by 0x1C49AD: milkymist_init (milkymist.c:133)
==20652==    by 0x1EBBB2: main (vl.c:4249)

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 hw/lm32/milkymist.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c
index e0cec7d..4b8284f 100644
--- a/hw/lm32/milkymist.c
+++ b/hw/lm32/milkymist.c
@@ -86,7 +86,7 @@  milkymist_init(MachineState *machine)
     DriveInfo *dinfo;
     MemoryRegion *address_space_mem = get_system_memory();
     MemoryRegion *phys_sdram = g_new(MemoryRegion, 1);
-    qemu_irq irq[32], *cpu_irq;
+    qemu_irq irq[32], cpu_irq;
     int i;
     char *bios_filename;
     ResetInfo *reset_info;
@@ -130,8 +130,8 @@  milkymist_init(MachineState *machine)
                           2, 0x00, 0x89, 0x00, 0x1d, 1);
 
     /* create irq lines */
-    cpu_irq = qemu_allocate_irqs(cpu_irq_handler, cpu, 1);
-    env->pic_state = lm32_pic_init(*cpu_irq);
+    cpu_irq = qemu_allocate_irq(cpu_irq_handler, cpu, 0);
+    env->pic_state = lm32_pic_init(cpu_irq);
     for (i = 0; i < 32; i++) {
         irq[i] = qdev_get_gpio_in(env->pic_state, i);
     }