[06/10] hw/arm/palm.c: Fix misusing qemu_allocate_irqs

Message ID 1435830563-3072-7-git-send-email-zhaoshenglong@huawei.com
State New
Headers show

Commit Message

Shannon Zhao July 2, 2015, 9:49 a.m.
From: Shannon Zhao <shannon.zhao@linaro.org>

Use qemu_allocate_irq instead of qemu_allocate_irqs to fix memory leak.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 hw/arm/palm.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

Patch

diff --git a/hw/arm/palm.c b/hw/arm/palm.c
index 7f1cfb8..f73c8a2 100644
--- a/hw/arm/palm.c
+++ b/hw/arm/palm.c
@@ -158,21 +158,25 @@  static void palmte_onoff_gpios(void *opaque, int line, int level)
 
 static void palmte_gpio_setup(struct omap_mpu_state_s *cpu)
 {
-    qemu_irq *misc_gpio;
-
     omap_mmc_handlers(cpu->mmc,
                     qdev_get_gpio_in(cpu->gpio, PALMTE_MMC_WP_GPIO),
                     qemu_irq_invert(omap_mpuio_in_get(cpu->mpuio)
                             [PALMTE_MMC_SWITCH_GPIO]));
 
-    misc_gpio = qemu_allocate_irqs(palmte_onoff_gpios, cpu, 7);
-    qdev_connect_gpio_out(cpu->gpio, PALMTE_MMC_POWER_GPIO,	misc_gpio[0]);
-    qdev_connect_gpio_out(cpu->gpio, PALMTE_SPEAKER_GPIO,	misc_gpio[1]);
-    qdev_connect_gpio_out(cpu->gpio, 11,			misc_gpio[2]);
-    qdev_connect_gpio_out(cpu->gpio, 12,			misc_gpio[3]);
-    qdev_connect_gpio_out(cpu->gpio, 13,			misc_gpio[4]);
-    omap_mpuio_out_set(cpu->mpuio, 1,				misc_gpio[5]);
-    omap_mpuio_out_set(cpu->mpuio, 3,				misc_gpio[6]);
+    qdev_connect_gpio_out(cpu->gpio, PALMTE_MMC_POWER_GPIO,
+                          qemu_allocate_irq(palmte_onoff_gpios, cpu, 0));
+    qdev_connect_gpio_out(cpu->gpio, PALMTE_SPEAKER_GPIO,
+                          qemu_allocate_irq(palmte_onoff_gpios, cpu, 1));
+    qdev_connect_gpio_out(cpu->gpio, 11,
+                          qemu_allocate_irq(palmte_onoff_gpios, cpu, 2));
+    qdev_connect_gpio_out(cpu->gpio, 12,
+                          qemu_allocate_irq(palmte_onoff_gpios, cpu, 3));
+    qdev_connect_gpio_out(cpu->gpio, 13,
+                          qemu_allocate_irq(palmte_onoff_gpios, cpu, 4));
+    omap_mpuio_out_set(cpu->mpuio, 1,
+                       qemu_allocate_irq(palmte_onoff_gpios, cpu, 5));
+    omap_mpuio_out_set(cpu->mpuio, 3,
+                       qemu_allocate_irq(palmte_onoff_gpios, cpu, 6));
 
     /* Reset some inputs to initial state.  */
     qemu_irq_lower(qdev_get_gpio_in(cpu->gpio, PALMTE_USBDETECT_GPIO));