[04/29] hw/i386/pc_q35.c: Fix memory leak spotted by valgrind

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

Commit Message

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

valgrind complains about:
==25058== 128 bytes in 1 blocks are definitely lost in loss record 2,624 of 3,473
==25058==    at 0x4C2845D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==25058==    by 0x2EB657: malloc_and_trace (vl.c:2556)
==25058==    by 0x64C71F5: ??? (in /usr/lib64/libglib-2.0.so.0.3600.3)
==25058==    by 0x64C7766: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.3600.3)
==25058==    by 0x3C62B2: i8259_init (i8259.c:475)
==25058==    by 0x255AF4: pc_q35_init (pc_q35.c:232)
==25058==    by 0x2EFA22: main (vl.c:4249)

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 hw/i386/pc_q35.c | 1 +
 1 file changed, 1 insertion(+)

Patch

diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index f2e3cf7..1a311dc 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -235,6 +235,7 @@  static void pc_q35_init(MachineState *machine)
     for (i = 0; i < ISA_NUM_IRQS; i++) {
         gsi_state->i8259_irq[i] = i8259[i];
     }
+    g_free(i8259);
     if (pci_enabled) {
         ioapic_init_gsi(gsi_state, "q35");
     }