From patchwork Thu May 28 12:39:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49097 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 F1FE1218EC for ; Thu, 28 May 2015 12:43:02 +0000 (UTC) Received: by wgez8 with SMTP id z8sf9859495wge.2 for ; Thu, 28 May 2015 05:43:02 -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=WeqHNnhkUgqik154D7QANEGhWcgb/m8i2p9MwPC43qg=; b=Z1UhfBCtyLQ81BjA0TIIj6kT9sYS21eF+WQMu2moBsoI8A/SWoUoc74Z2BYU+86TV8 Cs729bmrttgaCZ7zH6FVx6Uzw5Okz6DznJ1jZWBrUYuO4Ontwa0PHvbd20YbJ67NuA7d cZ/jyLSgIiOFiMeTh5eX5UloOnEu3aNnjf2EUIKIUIeF5UG4b/VGWY68Nnj1+WsEKKsh DHpui0/JRulKVY73Rs7T8fJF94t6M7X0DBCtYB2AmMBf9TARZf7eMWGyp5M2+QKjroHC RiGE29gXIHzr6adcKRDe+N5ycasFs4P0bBjKiJH64s20BjFYLoUC6Mizop/DbnLdgyxj AjXQ== X-Gm-Message-State: ALoCoQmIAr+egHavArrU6F8QQ4/Jutatrb5IpV46ZRG6bfXfYt6g7T43dfTsMorp0A1kxngn0FPS X-Received: by 10.112.26.5 with SMTP id h5mr2612726lbg.4.1432816982300; Thu, 28 May 2015 05:43:02 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.71 with SMTP id t7ls192393lae.31.gmail; Thu, 28 May 2015 05:43:02 -0700 (PDT) X-Received: by 10.112.25.69 with SMTP id a5mr2613930lbg.16.1432816982180; Thu, 28 May 2015 05:43:02 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id t8si1836414lae.163.2015.05.28.05.43.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 May 2015 05:43:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by lagv1 with SMTP id v1so30648808lag.3 for ; Thu, 28 May 2015 05:43:02 -0700 (PDT) X-Received: by 10.112.220.7 with SMTP id ps7mr2571301lbc.72.1432816982090; Thu, 28 May 2015 05:43:02 -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 hn6csp1127993lbb; Thu, 28 May 2015 05:43:01 -0700 (PDT) X-Received: by 10.55.33.6 with SMTP id h6mr4535762qkh.99.1432816980868; Thu, 28 May 2015 05:43:00 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k39si2215861qgk.87.2015.05.28.05.43.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 28 May 2015 05:43:00 -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]:58707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxx9H-00032f-Gs for patch@linaro.org; Thu, 28 May 2015 08:42:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxx6s-0007gp-Hm for qemu-devel@nongnu.org; Thu, 28 May 2015 08:40:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yxx6k-0007sd-OT for qemu-devel@nongnu.org; Thu, 28 May 2015 08:40:30 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:57982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yxx6k-0007jS-2B; Thu, 28 May 2015 08:40:22 -0400 Received: from 172.24.2.119 (EHLO szxeml426-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id COQ01167; Thu, 28 May 2015 20:40:08 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml426-hub.china.huawei.com (10.82.67.181) with Microsoft SMTP Server id 14.3.158.1; Thu, 28 May 2015 20:39:57 +0800 From: Shannon Zhao To: Date: Thu, 28 May 2015 20:39:42 +0800 Message-ID: <1432816784-12436-3-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1432816784-12436-1-git-send-email-zhaoshenglong@huawei.com> References: <1432816784-12436-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 v2 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.54 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 Signed-off-by: Michael Tokarev --- hw/alpha/dp264.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index 9fe7e8b..f86e7bb 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -55,7 +55,7 @@ static void clipper_init(MachineState *machine) ISABus *isa_bus; qemu_irq rtc_irq; long size, i; - const char *palcode_filename; + char *palcode_filename; uint64_t palcode_entry, palcode_low, palcode_high; uint64_t kernel_entry, kernel_low, kernel_high; @@ -101,8 +101,8 @@ static void clipper_init(MachineState *machine) /* Load PALcode. Given that this is not "real" cpu palcode, 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); + palcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, + bios_name ? bios_name : "palcode-clipper"); if (palcode_filename == NULL) { hw_error("no palcode provided\n"); exit(1); @@ -114,6 +114,7 @@ static void clipper_init(MachineState *machine) hw_error("could not load palcode '%s'\n", palcode_filename); exit(1); } + g_free(palcode_filename); /* Start all cpus at the PALcode RESET entry point. */ for (i = 0; i < smp_cpus; ++i) {