From patchwork Thu May 28 11:13:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49057 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B520A218EC for ; Thu, 28 May 2015 11:17:11 +0000 (UTC) Received: by wgv5 with SMTP id 5sf5045159wgv.0 for ; Thu, 28 May 2015 04:17:11 -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=L64yi4iFdIWazOnl9tMhhZcggMrEC7MLb5QfTaBhRzI=; b=VrPe99J3DY2krilZLMGlABx9Xo3wo3oRpDFyKnIjkTKayXc2OlHFC7AIUDVSzz+k42 Vk8N+jUJdgSU340wLAVd1bMQeLMY1K2pSt9FBrwiHweo3p+g7BBOqv/WIjL8sY1dLc+M bCPwdyXDGWp4LCLMtBIOg3eEoBdbAmXpsI0fCf8wVFpkrL3QE65E4pOvxpNTGPIGsXeJ KKrXlOHcBAhEWSBRe9zBweG6cblsSGtXt6IuonhX9XIO9HYBvbnkSac8Tm3zWoHtExt1 af2NmTJXqGs+d6K3gSzhg/b4hWcMcxv5rfR4FaSOefHy/IAfQILJnZrf8osyUGYVoiCR Magw== X-Gm-Message-State: ALoCoQlLrAfyHruJ9DciieNhXEE4jEp8bm2vGoPe46BAY7NEAMjypdCI96rbe4632cNJlejzGmpM X-Received: by 10.180.84.67 with SMTP id w3mr25616677wiy.7.1432811831064; Thu, 28 May 2015 04:17:11 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.163.37 with SMTP id yf5ls92540lab.17.gmail; Thu, 28 May 2015 04:17:10 -0700 (PDT) X-Received: by 10.152.87.108 with SMTP id w12mr2219792laz.57.1432811830917; Thu, 28 May 2015 04:17:10 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id l7si1669305lae.121.2015.05.28.04.17.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 May 2015 04:17:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by laat2 with SMTP id t2so28960569laa.1 for ; Thu, 28 May 2015 04:17:10 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr2218394lae.19.1432811830638; Thu, 28 May 2015 04:17:10 -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 hn6csp1070314lbb; Thu, 28 May 2015 04:17:09 -0700 (PDT) X-Received: by 10.140.94.246 with SMTP id g109mr2318002qge.101.1432811829391; Thu, 28 May 2015 04:17:09 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 145si2036928qhu.43.2015.05.28.04.17.08 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 28 May 2015 04:17:09 -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]:57742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxvoB-0007On-Ly for patch@linaro.org; Thu, 28 May 2015 07:17:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxvlt-0004Hj-S4 for qemu-devel@nongnu.org; Thu, 28 May 2015 07:14:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yxvls-0001XG-M2 for qemu-devel@nongnu.org; Thu, 28 May 2015 07:14:45 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:18562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxvln-0001Jr-Vm; Thu, 28 May 2015 07:14:40 -0400 Received: from 172.24.2.119 (EHLO szxeml432-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CMA87047; Thu, 28 May 2015 19:14:25 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml432-hub.china.huawei.com (10.82.67.209) with Microsoft SMTP Server id 14.3.158.1; Thu, 28 May 2015 19:14:16 +0800 From: Shannon Zhao To: Date: Thu, 28 May 2015 19:13:43 +0800 Message-ID: <1432811625-13392-3-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1432811625-13392-1-git-send-email-zhaoshenglong@huawei.com> References: <1432811625-13392-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 Subject: [Qemu-devel] [PATCH 2/4] hw/alpha/dp264.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.44 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: ==7055== 58 bytes in 1 blocks are definitely lost in loss record 1,471 of 2,192 ==7055== at 0x4C2845D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==7055== by 0x24410F: malloc_and_trace (vl.c:2556) ==7055== by 0x64C770E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3600.3) ==7055== by 0x64DEFD7: g_strndup (in /usr/lib64/libglib-2.0.so.0.3600.3) ==7055== by 0x650181A: g_vasprintf (in /usr/lib64/libglib-2.0.so.0.3600.3) ==7055== by 0x64DF0CC: g_strdup_vprintf (in /usr/lib64/libglib-2.0.so.0.3600.3) ==7055== by 0x64DF188: g_strdup_printf (in /usr/lib64/libglib-2.0.so.0.3600.3) ==7055== by 0x242F81: qemu_find_file (vl.c:2121) ==7055== by 0x217A32: clipper_init (dp264.c:105) ==7055== by 0x2484DA: main (vl.c:4249) Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/alpha/dp264.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index 9fe7e8b..0c5395f 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -56,6 +56,7 @@ static void clipper_init(MachineState *machine) qemu_irq rtc_irq; long size, i; const char *palcode_filename; + char *filename; uint64_t palcode_entry, palcode_low, palcode_high; uint64_t kernel_entry, kernel_low, kernel_high; @@ -102,18 +103,20 @@ static void clipper_init(MachineState *machine) but one explicitly written for the emulation, we might as well load it directly from and ELF image. */ palcode_filename = (bios_name ? bios_name : "palcode-clipper"); - palcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, palcode_filename); - if (palcode_filename == NULL) { + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, palcode_filename); + if (filename == NULL) { hw_error("no palcode provided\n"); exit(1); } - size = load_elf(palcode_filename, cpu_alpha_superpage_to_phys, + size = load_elf(filename, cpu_alpha_superpage_to_phys, NULL, &palcode_entry, &palcode_low, &palcode_high, 0, EM_ALPHA, 0); if (size < 0) { - hw_error("could not load palcode '%s'\n", palcode_filename); + hw_error("could not load palcode '%s'\n", filename); + g_free(filename); exit(1); } + g_free(filename); /* Start all cpus at the PALcode RESET entry point. */ for (i = 0; i < smp_cpus; ++i) {