From patchwork Thu May 28 12:08:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49070 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3D657218EC for ; Thu, 28 May 2015 12:15:38 +0000 (UTC) Received: by lagv1 with SMTP id v1sf10585015lag.1 for ; Thu, 28 May 2015 05:15:37 -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=7mYg8dToLJysGsQzqSAjVykN4PLeldXndlnmixQGe1E=; b=ezx986EghQ0AuWN01brI6Ftrxso9nHLyGSKB2yeYD5GcTc4pbFYPjTpb790BGg55gg AR9F++0oSMzXW6Z1mxCQvOlDt1fRGehOghxWJpEvmWerElsfW6x7xqpJwUNPeZBCsGub WIQIStVeg6rc/bPbwh6BShab2xV0vTnv8RxAA48lfksweG2aZ+XDWTaQm8IBSLzOB4xz twvMnE0hfHQMgxXX6ykc0mwI6VaRm51eN9nljJai9Zsq+znOER3nWlO+46gv9fnB6VCR n3lbF9PWiKxu/0NfIZJFtg0WszKbJPrL1wY+Z4XI3lpbgGp/l+i8R6TQGccSRw1MevyT J0Sg== X-Gm-Message-State: ALoCoQklweMI/Wmo41Gj/OOuemzFc6tsGUnx0oPruFdXJeSAAUndJTPTjSKSFIK847jTh5Mw4U5W X-Received: by 10.194.47.179 with SMTP id e19mr2450198wjn.4.1432815337008; Thu, 28 May 2015 05:15:37 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.202 with SMTP id l10ls193057laa.5.gmail; Thu, 28 May 2015 05:15:36 -0700 (PDT) X-Received: by 10.112.64.193 with SMTP id q1mr2416717lbs.11.1432815336877; Thu, 28 May 2015 05:15:36 -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 p1si1812781lag.52.2015.05.28.05.15.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 May 2015 05:15:36 -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 lbbuc2 with SMTP id uc2so26832452lbb.2 for ; Thu, 28 May 2015 05:15:36 -0700 (PDT) X-Received: by 10.152.6.69 with SMTP id y5mr2444854lay.72.1432815336791; Thu, 28 May 2015 05:15:36 -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 hn6csp1108818lbb; Thu, 28 May 2015 05:15:35 -0700 (PDT) X-Received: by 10.140.98.237 with SMTP id o100mr2681926qge.1.1432815335472; Thu, 28 May 2015 05:15:35 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p6si230363qgp.114.2015.05.28.05.15.34 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 28 May 2015 05:15:35 -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]:58339 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxwik-0001gR-Gw for patch@linaro.org; Thu, 28 May 2015 08:15:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxwe7-0002FX-0N 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 1Yxwe0-0003Wc-Sv for qemu-devel@nongnu.org; Thu, 28 May 2015 08:10:46 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:45247) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxwe0-0003VJ-1N; Thu, 28 May 2015 08:10:40 -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 COP98100; Thu, 28 May 2015 20:10:31 +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:04 +0800 From: Shannon Zhao To: Date: Thu, 28 May 2015 20:08:35 +0800 Message-ID: <1432814932-12608-13-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 12/29] hw/ppc/ppc440_bamboo.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: ==6366== 4,936 (256 direct, 4,680 indirect) bytes in 1 blocks are definitely lost in loss record 3,245 of 3,271 ==6366== at 0x4C2845D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==6366== by 0x336F47: malloc_and_trace (vl.c:2556) ==6366== by 0x64C770E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3600.3) ==6366== by 0x3C093B: qemu_extend_irqs (irq.c:55) ==6366== by 0x3C09C7: qemu_allocate_irqs (irq.c:64) ==6366== by 0x265091: ppcuic_init (ppc4xx_devs.c:317) ==6366== by 0x26A90A: bamboo_init (ppc440_bamboo.c:205) ==6366== by 0x33B312: main (vl.c:4249) Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/ppc/ppc440_bamboo.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 778970a..23b091f 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -235,13 +235,28 @@ static void bamboo_init(MachineState *machine) serial_mm_init(address_space_mem, 0xef600300, 0, pic[0], PPC_SERIAL_MM_BAUDBASE, serial_hds[0], DEVICE_BIG_ENDIAN); + } else { + qemu_free_irq(pic[0]); } if (serial_hds[1] != NULL) { serial_mm_init(address_space_mem, 0xef600400, 0, pic[1], PPC_SERIAL_MM_BAUDBASE, serial_hds[1], DEVICE_BIG_ENDIAN); + } else { + qemu_free_irq(pic[1]); } + for (i = 2; i < 14; i++) { + qemu_free_irq(pic[i]); + } + for (i = 15; i < 25; i++) { + qemu_free_irq(pic[i]); + } + for (i = 29; i < 32; i++) { + qemu_free_irq(pic[i]); + } + g_free(pic); + if (pcibus) { /* Register network interfaces. */ for (i = 0; i < nb_nics; i++) {