From patchwork Tue May 26 01:46:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 48969 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9E72B2121F for ; Tue, 26 May 2015 01:51:15 +0000 (UTC) Received: by wifq9 with SMTP id q9sf17464760wif.3 for ; Mon, 25 May 2015 18:51:14 -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=ScIV9e9gmO8VYoD3UzNc+yBhbZzF4drTu1FnMDqrC9Q=; b=G6r52q7Z4PZ5gTG8aJvlVx9ukH9UHmTCc35eUGGwl5lWvZ9qanPX95fxgNiwdR26Sb 4Mf9M4qBuWKOxmwic9nVXR/IQh1Gh+qX/fcx5S8dLnZbwhpx+bMdoUfyMrdTqkwTAPiq vj6x4UrR3ScPI3VVVb2Zv9Oa/DhyA7QT7Xd9AXm3XALrd8IqraZPb4R3H1CDBzZq7uyN huOQ3akbyXIMhyNIiGeWy7bEOxmmv2Ce/0kTcJVEbQ8Sr+x5MFDf3fBkFl6HF/Kf0CK1 /ON91LUvOhDTuGGc7Wm6U0yJoT0Dnwoz748PjLSr0Y06Oi0V5gn2ZrEFlSCvFD5sR6RH h2JA== X-Gm-Message-State: ALoCoQm9ZK6/MB6X/w0bPDWEr4FgAhBoYIgOyW5xkNUtijOrOMCs1vToIL1kUy9F3Iow9UwwjIwZ X-Received: by 10.180.106.136 with SMTP id gu8mr21168653wib.6.1432605074951; Mon, 25 May 2015 18:51:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.180.202 with SMTP id dq10ls833119lac.109.gmail; Mon, 25 May 2015 18:51:14 -0700 (PDT) X-Received: by 10.112.47.73 with SMTP id b9mr20234730lbn.46.1432605074754; Mon, 25 May 2015 18:51:14 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id kh8si8057883lbc.46.2015.05.25.18.51.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 May 2015 18:51:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbuc2 with SMTP id uc2so60375505lbb.2 for ; Mon, 25 May 2015 18:51:14 -0700 (PDT) X-Received: by 10.152.206.75 with SMTP id lm11mr19992442lac.41.1432605074438; Mon, 25 May 2015 18:51:14 -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 hn6csp2191392lbb; Mon, 25 May 2015 18:51:13 -0700 (PDT) X-Received: by 10.55.50.84 with SMTP id y81mr49635865qky.98.1432605073593; Mon, 25 May 2015 18:51:13 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 8si6890038qkr.105.2015.05.25.18.51.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 25 May 2015 18:51:13 -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]:45491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yx41Q-0003Hi-L5 for patch@linaro.org; Mon, 25 May 2015 21:51:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yx407-0001O3-Qy for qemu-devel@nongnu.org; Mon, 25 May 2015 21:49:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yx406-000366-Pu for qemu-devel@nongnu.org; Mon, 25 May 2015 21:49:51 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:24407) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yx403-00034V-Gr; Mon, 25 May 2015 21:49:48 -0400 Received: from 172.24.2.119 (EHLO szxeml427-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BGN88726; Tue, 26 May 2015 09:46:27 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.158.1; Tue, 26 May 2015 09:46:18 +0800 From: Shannon Zhao To: Date: Tue, 26 May 2015 09:46:05 +0800 Message-ID: <1432604767-5964-2-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1432604767-5964-1-git-send-email-zhaoshenglong@huawei.com> References: <1432604767-5964-1-git-send-email-zhaoshenglong@huawei.com> 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.5563D073.010A, 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: d722a8d7b451eebc97a8edc34edc89d1 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, shannon.zhao@linaro.org Subject: [Qemu-devel] [PATCH v2 1/3] hw/i386/pc_piix: Fix memory leak 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.182 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: ==16447== 8 bytes in 1 blocks are definitely lost in loss record 552 of 3,310 ==16447== at 0x4C2845D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==16447== by 0x2E4FD7: malloc_and_trace (vl.c:2546) ==16447== by 0x64C770E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3600.3) ==16447== by 0x36FB47: qemu_extend_irqs (irq.c:55) ==16447== by 0x36FBD3: qemu_allocate_irqs (irq.c:64) ==16447== by 0x24E622: pc_init1 (pc_piix.c:287) ==16447== by 0x24E76A: pc_init_pci (pc_piix.c:310) ==16447== by 0x2E9360: main (vl.c:4226) ==16447== 128 bytes in 1 blocks are definitely lost in loss record 2,569 of 3,310 ==16447== at 0x4C2845D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==16447== by 0x2E4FD7: malloc_and_trace (vl.c:2546) ==16447== by 0x64C770E: g_malloc (in /usr/lib64/libglib-2.0.so.0.3600.3) ==16447== by 0x36FB47: qemu_extend_irqs (irq.c:55) ==16447== by 0x36FBD3: qemu_allocate_irqs (irq.c:64) ==16447== by 0x25BEB2: kvm_i8259_init (i8259.c:133) ==16447== by 0x24E1F1: pc_init1 (pc_piix.c:219) ==16447== by 0x24E76A: pc_init_pci (pc_piix.c:310) ==16447== by 0x2E9360: main (vl.c:4226) Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/i386/pc_piix.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 1fe7bfb..d567887 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -89,7 +89,7 @@ static void pc_init1(MachineState *machine, qemu_irq *cpu_irq; qemu_irq *gsi; qemu_irq *i8259; - qemu_irq *smi_irq; + qemu_irq smi_irq; GSIState *gsi_state; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; BusState *idebus[MAX_IDE_BUS]; @@ -227,6 +227,7 @@ static void pc_init1(MachineState *machine, for (i = 0; i < ISA_NUM_IRQS; i++) { gsi_state->i8259_irq[i] = i8259[i]; } + g_free(i8259); if (pci_enabled) { ioapic_init_gsi(gsi_state, "i440fx"); } @@ -284,10 +285,10 @@ static void pc_init1(MachineState *machine, DeviceState *piix4_pm; I2CBus *smbus; - smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1); + smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); /* TODO: Populate SPD eeprom data. */ smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, - gsi[9], *smi_irq, + gsi[9], smi_irq, kvm_enabled(), fw_cfg, &piix4_pm); smbus_eeprom_init(smbus, 8, NULL, 0);