From patchwork Fri May 29 05:38:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49140 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3B11A22B3A for ; Fri, 29 May 2015 05:39:43 +0000 (UTC) Received: by wgla2 with SMTP id a2sf15170685wgl.1 for ; Thu, 28 May 2015 22:39:41 -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 :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=dimO1Zh2/tZcKYcaPyxUf8urguAVACIBRLc882tUspI=; b=GhyfYCQGtSEe3jJnjRpK+FJsCa7FbkCamRZ89w/AReuw5VNzFW+WmEweQXuVayMfBD 8geFVeCTmR4E6vxXBBTWL6zgG6TFEE+7SGtI2naufrvGoBVqqkY5+N0LfKSZg94vNlJi w+Z1d2mGCfLdI/oJXcPsjXb9uqcvabsLGvrSlV8E9G3tNryXYx4/W+aPOWkRjtu+K9iS lnJ+ptu/w4v+OWu8ZO3Hiss3EIGjyrQLUkrWp/vOK1Y0trv3h4V8JddL28YCNk1nNNQp ZDYxk68ha87RPqedNhq+K0SfRhbvs2QzZwhzaxZGlhzCZt93bEJaMP6IC/OBE6R0J0yP /WJQ== X-Gm-Message-State: ALoCoQkk7Kq6ApJ7OUlY5M1gq5YKdUeqs8cs5cqvilKvV50ZOAQxSubS+MmlArmMTX9D9ExMdkpi X-Received: by 10.112.97.210 with SMTP id ec18mr5827312lbb.15.1432877981763; Thu, 28 May 2015 22:39:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.178.164 with SMTP id cz4ls309319lac.3.gmail; Thu, 28 May 2015 22:39:41 -0700 (PDT) X-Received: by 10.112.136.166 with SMTP id qb6mr6364543lbb.54.1432877981648; Thu, 28 May 2015 22:39:41 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id c10si3766333laa.171.2015.05.28.22.39.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 May 2015 22:39:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by labpy14 with SMTP id py14so36116015lab.0 for ; Thu, 28 May 2015 22:39:41 -0700 (PDT) X-Received: by 10.112.29.36 with SMTP id g4mr6416840lbh.56.1432877981387; Thu, 28 May 2015 22:39:41 -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 hn6csp37314lbb; Thu, 28 May 2015 22:39:40 -0700 (PDT) X-Received: by 10.55.40.66 with SMTP id o63mr12605850qkh.47.1432877980185; Thu, 28 May 2015 22:39:40 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b39si4706653qkh.21.2015.05.28.22.39.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 28 May 2015 22:39:40 -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]:33631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyD19-0006cT-CR for patch@linaro.org; Fri, 29 May 2015 01:39:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyD0d-0006GV-TY for qemu-devel@nongnu.org; Fri, 29 May 2015 01:39:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyD0c-0000fU-Sf for qemu-devel@nongnu.org; Fri, 29 May 2015 01:39:07 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:25173) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyD0X-0000ea-Kq; Fri, 29 May 2015 01:39:02 -0400 Received: from 172.24.2.119 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BGS74890; Fri, 29 May 2015 13:38:50 +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; Fri, 29 May 2015 13:38:42 +0800 From: Shannon Zhao To: Date: Fri, 29 May 2015 13:38:34 +0800 Message-ID: <1432877914-13552-1-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.5567FB6B.006D, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 8bb665d00a7629fbf5d6d9bcaf2f3a79 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Cc: qemu-trivial@nongnu.org, mjt@tls.msk.ru, shannon.zhao@linaro.org Subject: [Qemu-devel] [PATCH v2] hw/arm/omap_sx1.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.215.42 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: ==19440== 248 bytes in 1 blocks are definitely lost in loss record 2,340 of 2,934 ==19440== at 0x4C2845D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==19440== by 0x354793: malloc_and_trace (vl.c:2556) ==19440== by 0x64C770E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3600.3) ==19440== by 0x2833DB: sx1_init (omap_sx1.c:106) ==19440== by 0x2838C9: sx1_init_v2 (omap_sx1.c:217) ==19440== by 0x358B5E: main (vl.c:4249) Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- This is split from my previous patchset [1] [1] [PATCH 00/29] Fix memory leak relevant to calling qemu_allocate_irqs --- hw/arm/omap_sx1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c index 671e02c..4b0f7f9 100644 --- a/hw/arm/omap_sx1.c +++ b/hw/arm/omap_sx1.c @@ -103,7 +103,6 @@ static void sx1_init(MachineState *machine, const int version) struct omap_mpu_state_s *mpu; MemoryRegion *address_space = get_system_memory(); MemoryRegion *flash = g_new(MemoryRegion, 1); - MemoryRegion *flash_1 = g_new(MemoryRegion, 1); MemoryRegion *cs = g_new(MemoryRegion, 4); static uint32_t cs0val = 0x00213090; static uint32_t cs1val = 0x00215070; @@ -165,6 +164,7 @@ static void sx1_init(MachineState *machine, const int version) if ((version == 1) && (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { + MemoryRegion *flash_1 = g_new(MemoryRegion, 1); memory_region_init_ram(flash_1, NULL, "omap_sx1.flash1-0", flash1_size, &error_abort); vmstate_register_ram_global(flash_1);