From patchwork Mon Sep 24 19:08:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 186519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BE09A2C008D for ; Tue, 25 Sep 2012 05:09:35 +1000 (EST) Received: from localhost ([::1]:39381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGE29-0007Hz-Pq for incoming@patchwork.ozlabs.org; Mon, 24 Sep 2012 15:09:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGE1Z-0005tk-Ij for qemu-devel@nongnu.org; Mon, 24 Sep 2012 15:08:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGE1X-0003sB-2L for qemu-devel@nongnu.org; Mon, 24 Sep 2012 15:08:57 -0400 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:38112) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGE1W-0003rt-Si for qemu-devel@nongnu.org; Mon, 24 Sep 2012 15:08:54 -0400 Received: from localhost (v220110690675601.yourvserver.net.local [127.0.0.1]) by v220110690675601.yourvserver.net (Postfix) with ESMTP id 81E0F728003C; Mon, 24 Sep 2012 21:08:54 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at weilnetz.de Received: from v220110690675601.yourvserver.net ([127.0.0.1]) by localhost (v220110690675601.yourvserver.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EgTnkizO6xL8; Mon, 24 Sep 2012 21:08:54 +0200 (CEST) Received: by v220110690675601.yourvserver.net (Postfix, from userid 1000) id 1411D728003D; Mon, 24 Sep 2012 21:08:54 +0200 (CEST) From: Stefan Weil To: qemu-devel@nongnu.org Date: Mon, 24 Sep 2012 21:08:50 +0200 Message-Id: <1348513730-7485-4-git-send-email-sw@weilnetz.de> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1348513730-7485-1-git-send-email-sw@weilnetz.de> References: <1348513730-7485-1-git-send-email-sw@weilnetz.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 78.47.199.172 Cc: Stefan Weil Subject: [Qemu-devel] [PATCH 3/3] hw/spitz: Fix memory leaks (detected by Valgrind) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Signed-off-by: Stefan Weil --- 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);