[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/3] hw/spitz: Fix memory leaks (detected by Valgrin
From: |
Stefan Weil |
Subject: |
[Qemu-devel] [PATCH 3/3] hw/spitz: Fix memory leaks (detected by Valgrind) |
Date: |
Mon, 24 Sep 2012 21:08:50 +0200 |
outsignals was allocated using g_malloc and never released.
It is not necessary to use dynamic memory allocation
for that array because its entries are copied
and not used otherwise. Only 7 entries are used.
lcd_hsync can be initialized directly instead of copying the first entry
of a dynamically allocated array which is never released.
Cc: Andrzej Zaborowski <address@hidden>
Signed-off-by: Stefan Weil <address@hidden>
---
hw/spitz.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/spitz.c b/hw/spitz.c
index 20e7835..90dc35b 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -798,7 +798,8 @@ static void spitz_out_switch(void *opaque, int line, int
level)
static void spitz_scoop_gpio_setup(PXA2xxState *cpu,
DeviceState *scp0, DeviceState *scp1)
{
- qemu_irq *outsignals = qemu_allocate_irqs(spitz_out_switch, cpu, 8);
+ qemu_irq outsignals[7];
+ qemu_init_irqs(spitz_out_switch, cpu, outsignals, ARRAY_SIZE(outsignals));
qdev_connect_gpio_out(scp0, SPITZ_SCP_CHRG_ON, outsignals[0]);
qdev_connect_gpio_out(scp0, SPITZ_SCP_JK_B, outsignals[1]);
@@ -842,7 +843,7 @@ static void spitz_gpio_setup(PXA2xxState *cpu, int slots)
* wouldn't guarantee that a guest ever exits the loop.
*/
spitz_hsync = 0;
- lcd_hsync = qemu_allocate_irqs(spitz_lcd_hsync_handler, cpu, 1)[0];
+ qemu_init_irqs(spitz_lcd_hsync_handler, cpu, &lcd_hsync, 1);
pxa2xx_gpio_read_notifier(cpu->gpio, lcd_hsync);
pxa2xx_lcd_vsync_notifier(cpu->lcd, lcd_hsync);
--
1.7.10