[02/29] hw/ide/cmd646.c: Fix memory leak spotted by valgrind

Message ID 1432814932-12608-3-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:
==23215== 32 bytes in 2 blocks are definitely lost in loss record 1,356 of 2,329
==23215==    at 0x4C2845D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==23215==    by 0x27482B: malloc_and_trace (vl.c:2556)
==23215==    by 0x64C770E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3600.3)
==23215==    by 0x2EEFD3: qemu_extend_irqs (irq.c:55)
==23215==    by 0x2EF05F: qemu_allocate_irqs (irq.c:64)
==23215==    by 0x305498: pci_cmd646_ide_realize (cmd646.c:364)
==23215==    by 0x33DB29: pci_qdev_realize (pci.c:1781)
==23215==    by 0x2EBB14: device_set_realized (qdev.c:1058)
==23215==    by 0x3C1A0E: property_set_bool (object.c:1514)
==23215==    by 0x3C0308: object_property_set (object.c:837)
==23215==    by 0x3C262A: object_property_set_qobject (qom-qobject.c:24)
==23215==    by 0x3C0577: object_property_set_bool (object.c:905)

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

Patch

diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index 66fb9d9..c9703e2 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -370,6 +370,7 @@  static void pci_cmd646_ide_realize(PCIDevice *dev, Error **errp)
         d->bmdma[i].bus = &d->bus[i];
         ide_register_restart_cb(&d->bus[i]);
     }
+    g_free(irq);
 
     vmstate_register(DEVICE(dev), 0, &vmstate_ide_pci, d);
     qemu_register_reset(cmd646_reset, d);