[2/3] hw/arm_timer: Fix memory leak (detected by Valgrind)

Submitted by Stefan Weil on Sept. 24, 2012, 7:08 p.m.

Details

Message ID 1348513730-7485-3-git-send-email-sw@weilnetz.de
State New
Headers show

Commit Message

Stefan Weil Sept. 24, 2012, 7:08 p.m.
qi was allocated using g_malloc and never released.

It is not necessary to use dynamic memory allocation
for qi because it is copied to entries in s->timer
and not used otherwise.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 hw/arm_timer.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/hw/arm_timer.c b/hw/arm_timer.c
index e3ecce2..9e5f892 100644
--- a/hw/arm_timer.c
+++ b/hw/arm_timer.c
@@ -269,9 +269,8 @@  static const VMStateDescription vmstate_sp804 = {
 static int sp804_init(SysBusDevice *dev)
 {
     sp804_state *s = FROM_SYSBUS(sp804_state, dev);
-    qemu_irq *qi;
-
-    qi = qemu_allocate_irqs(sp804_set_irq, s, 2);
+    qemu_irq qi[2];
+    qemu_init_irqs(sp804_set_irq, s, qi, ARRAY_SIZE(qi));
     sysbus_init_irq(dev, &s->irq);
     s->timer[0] = arm_timer_init(s->freq0);
     s->timer[1] = arm_timer_init(s->freq1);