From patchwork Thu May 28 12:08:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49072 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CF29B218EC for ; Thu, 28 May 2015 12:17:09 +0000 (UTC) Received: by lani11 with SMTP id i11sf10569322lan.3 for ; Thu, 28 May 2015 05:17:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:content-type:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=H8QCVQIBuoFqLGmNtjx+6lr4Du8MlaZE55FvJoMiap0=; b=a8PlvtwT3JWW98sIUbi41H7gA13pArAwosJMQ/tIQGC5iJcdXd9I+W7DOJa263e7iP 6sjIqGYA3tlp94baNRMcs/6Udb1pdGbOrS0S6ql6TcnYb/wmS/Kzm7tcMEvfzF4tuam9 cZysfB6c2CeqW1ueVE0csQiUUQEJb/o/x7H8Jfll/wuxtWrqfvf/pNsN6REn+5JqQi8Z MtnBVe4jpbZW29ka/986cRAaHIT6EmoGcvqpZCHUxVxMn1SuLEK7YQs/ECDPftW77HU0 rH8W7LIe50RIjLIJ8mVLbzb928UHKmV8T8kiyL030nFBlf1yoKBc9jPV2wWZanXssqs2 xo6g== X-Gm-Message-State: ALoCoQl5q+7mA1D4OqY3/yd+SMjNpm8oMttyY/NTfY5HTBYQLtj7fW6Ik8E1f0aMBcWq7t9dmkdn X-Received: by 10.180.216.12 with SMTP id om12mr7533180wic.1.1432815428819; Thu, 28 May 2015 05:17:08 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.6 with SMTP id i6ls191462lam.4.gmail; Thu, 28 May 2015 05:17:08 -0700 (PDT) X-Received: by 10.112.185.100 with SMTP id fb4mr2484259lbc.79.1432815428689; Thu, 28 May 2015 05:17:08 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id dp7si1784594lbc.155.2015.05.28.05.17.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 May 2015 05:17:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbcmx3 with SMTP id mx3so26865197lbc.1 for ; Thu, 28 May 2015 05:17:08 -0700 (PDT) X-Received: by 10.112.234.200 with SMTP id ug8mr2405884lbc.117.1432815428608; Thu, 28 May 2015 05:17:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1110007lbb; Thu, 28 May 2015 05:17:07 -0700 (PDT) X-Received: by 10.229.248.199 with SMTP id mh7mr2824782qcb.23.1432815427328; Thu, 28 May 2015 05:17:07 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m65si2142303qge.101.2015.05.28.05.17.06 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 28 May 2015 05:17:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:58353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxwkE-0004Jp-83 for patch@linaro.org; Thu, 28 May 2015 08:17:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxwe8-0002GV-AE for qemu-devel@nongnu.org; Thu, 28 May 2015 08:10:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yxwe4-0003bR-1v for qemu-devel@nongnu.org; Thu, 28 May 2015 08:10:48 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:45280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxwe3-0003Zc-An; Thu, 28 May 2015 08:10:43 -0400 Received: from 172.24.2.119 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id COP98105; Thu, 28 May 2015 20:10:32 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.158.1; Thu, 28 May 2015 20:10:10 +0800 From: Shannon Zhao To: Date: Thu, 28 May 2015 20:08:41 +0800 Message-ID: <1432814932-12608-19-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1432814932-12608-1-git-send-email-zhaoshenglong@huawei.com> References: <1432814932-12608-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 58.251.152.64 Cc: qemu-trivial@nongnu.org, pbonzini@redhat.com, mjt@tls.msk.ru, shannon.zhao@linaro.org, peter.maydell@linaro.org Subject: [Qemu-devel] [PATCH 18/29] hw/m68k/mcf5206.c: Fix memory leak spotted 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Shannon Zhao valgrind complains about: ==16659== 1,912 (112 direct, 1,800 indirect) bytes in 1 blocks are definitely lost in loss record 1,254 of 1,285 ==16659== at 0x4C2845D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==16659== by 0x251F97: malloc_and_trace (vl.c:2556) ==16659== by 0x64C770E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3600.3) ==16659== by 0x2C994F: qemu_extend_irqs (irq.c:55) ==16659== by 0x2C99DB: qemu_allocate_irqs (irq.c:64) ==16659== by 0x225878: mcf5206_init (mcf5206.c:539) ==16659== by 0x223991: an5206_init (an5206.c:61) ==16659== by 0x256362: main (vl.c:4249) Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/m68k/mcf5206.c | 10 ++++++++-- include/hw/m68k/mcf.h | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c index 1727a46..67390e6 100644 --- a/hw/m68k/mcf5206.c +++ b/hw/m68k/mcf5206.c @@ -525,10 +525,11 @@ static const MemoryRegionOps m5206_mbar_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -qemu_irq *mcf5206_init(MemoryRegion *sysmem, uint32_t base, M68kCPU *cpu) +void mcf5206_init(MemoryRegion *sysmem, uint32_t base, M68kCPU *cpu) { m5206_mbar_state *s; qemu_irq *pic; + int i; s = (m5206_mbar_state *)g_malloc0(sizeof(m5206_mbar_state)); @@ -543,6 +544,11 @@ qemu_irq *mcf5206_init(MemoryRegion *sysmem, uint32_t base, M68kCPU *cpu) s->uart[1] = mcf_uart_init(pic[13], serial_hds[1]); s->cpu = cpu; + for (i = 0; i < 9; i++) { + qemu_free_irq(pic[i]); + } + qemu_free_irq(pic[11]); + g_free(pic); + m5206_mbar_reset(s); - return pic; } diff --git a/include/hw/m68k/mcf.h b/include/hw/m68k/mcf.h index fbc8dc2..9bf4f5f 100644 --- a/include/hw/m68k/mcf.h +++ b/include/hw/m68k/mcf.h @@ -24,7 +24,6 @@ void mcf_fec_init(struct MemoryRegion *sysmem, NICInfo *nd, hwaddr base, qemu_irq *irq); /* mcf5206.c */ -qemu_irq *mcf5206_init(struct MemoryRegion *sysmem, - uint32_t base, M68kCPU *cpu); +void mcf5206_init(struct MemoryRegion *sysmem, uint32_t base, M68kCPU *cpu); #endif