From patchwork Thu May 28 12:08:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49092 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 9DC11218EC for ; Thu, 28 May 2015 12:29:44 +0000 (UTC) Received: by wgv5 with SMTP id 5sf5490060wgv.0 for ; Thu, 28 May 2015 05:29:43 -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=2jEBQh845gCFL6JPbeqVNle0secXehfNp6N5Ag9J5To=; b=dAzxvk8BGxEQeJyUppCjJdsewmdiZa2yktFrTc3sAmHFsZDhY0caYnkT10yejrmjaK nfEW+mV9A2sHv0TwwarwrvFufppyWciQnvjlHp8IDJ+9N7eyiw71Lj6eHJGF3vk9YhMa tPKqLif4bLjPRDRVrHevJQI0yjQZWRVuglALW2/ULjVfpMekVrRF22bk9Nef4w4ahYjr Z+abq0/1ycGetj0vx6QuLrjiQE9wBIlNPTBosrDzXxuk0UPfUh4EJV9eerZFVJZqVBBh Wb/q68feFUirwkC99lUbjkrw1mBCYj8PgmSCywbAft4z317YPs8u17YLA9QToRe4fgH0 6zaA== X-Gm-Message-State: ALoCoQlp3cXgR+m/zfmu/fe3yUvrSlqGerwH3DkTqoOyXPZRkWH5jtWPUfWqg6TpodUQ1aLGIFwa X-Received: by 10.152.87.140 with SMTP id ay12mr2504608lab.8.1432816183856; Thu, 28 May 2015 05:29:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.193 with SMTP id 1ls188251law.41.gmail; Thu, 28 May 2015 05:29:43 -0700 (PDT) X-Received: by 10.152.42.230 with SMTP id r6mr2512613lal.30.1432816183744; Thu, 28 May 2015 05:29:43 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id of3si1823329lbb.110.2015.05.28.05.29.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 May 2015 05:29:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbcue7 with SMTP id ue7so27100941lbc.0 for ; Thu, 28 May 2015 05:29:43 -0700 (PDT) X-Received: by 10.112.220.7 with SMTP id ps7mr2509462lbc.72.1432816183310; Thu, 28 May 2015 05:29:43 -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 hn6csp1119009lbb; Thu, 28 May 2015 05:29:42 -0700 (PDT) X-Received: by 10.140.51.106 with SMTP id t97mr2759424qga.44.1432816181765; Thu, 28 May 2015 05:29:41 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z203si2180780qhd.94.2015.05.28.05.29.41 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 28 May 2015 05:29:41 -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]:58504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxwwO-0004Zg-GV for patch@linaro.org; Thu, 28 May 2015 08:29:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxwfQ-0004TD-U8 for qemu-devel@nongnu.org; Thu, 28 May 2015 08:12:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxwfM-0004MC-UM for qemu-devel@nongnu.org; Thu, 28 May 2015 08:12:08 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:42477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxwfM-0004KO-D3; Thu, 28 May 2015 08:12:04 -0400 Received: from 172.24.2.119 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CMA92615; Thu, 28 May 2015 20:11:54 +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:18 +0800 From: Shannon Zhao To: Date: Thu, 28 May 2015 20:08:47 +0800 Message-ID: <1432814932-12608-25-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: 119.145.14.65 Cc: qemu-trivial@nongnu.org, pbonzini@redhat.com, mjt@tls.msk.ru, shannon.zhao@linaro.org, peter.maydell@linaro.org Subject: [Qemu-devel] [PATCH 24/29] 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.217.172 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 --- 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);