qemu-trivial
[Top][All Lists]
Advanced

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

[Qemu-trivial] [PATCH 09/29] hw/sparc/leon3.c: Fix memory leak spotted b


From: Shannon Zhao
Subject: [Qemu-trivial] [PATCH 09/29] hw/sparc/leon3.c: Fix memory leak spotted by valgrind
Date: Thu, 28 May 2015 20:08:32 +0800

From: Shannon Zhao <address@hidden>

valgrind complains about:
==21199== 2,468 (128 direct, 2,340 indirect) bytes in 1 blocks are definitely 
lost in loss record 1,094 of 1,125
==21199==    at 0x4C2845D: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21199==    by 0x21B933: malloc_and_trace (vl.c:2556)
==21199==    by 0x64C770E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3600.3)
==21199==    by 0x2700D3: qemu_extend_irqs (irq.c:55)
==21199==    by 0x27015F: qemu_allocate_irqs (irq.c:64)
==21199==    by 0x1ED14D: grlib_irqmp_create (grlib.h:64)
==21199==    by 0x1ED6B9: leon3_generic_hw_init (leon3.c:142)
==21199==    by 0x21FCFE: main (vl.c:4249)

Signed-off-by: Shannon Zhao <address@hidden>
Signed-off-by: Shannon Zhao <address@hidden>
---
 hw/sparc/leon3.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index 7f5dcd6..c449b39 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -111,7 +111,7 @@ static void leon3_generic_hw_init(MachineState *machine)
     MemoryRegion *address_space_mem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     MemoryRegion *prom = g_new(MemoryRegion, 1);
-    int         ret;
+    int         ret, i;
     char       *filename;
     qemu_irq   *cpu_irqs = NULL;
     int         bios_size;
@@ -214,6 +214,13 @@ static void leon3_generic_hw_init(MachineState *machine)
     if (serial_hds[0]) {
         grlib_apbuart_create(0x80000100, serial_hds[0], cpu_irqs[3]);
     }
+
+    for (i = 0; i < MAX_PILS; i++) {
+        if ((i != 3) || (i != 6) || (i != 7)) {
+            qemu_free_irq(cpu_irqs[i]);
+        }
+    }
+    g_free(cpu_irqs);
 }
 
 static QEMUMachine leon3_generic_machine = {
-- 
2.0.4





reply via email to

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