From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkE7z-0001Hj-67 for qemu-devel@nongnu.org; Fri, 31 Oct 2014 11:29:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjvvU-0001yk-Fd for qemu-devel@nongnu.org; Thu, 30 Oct 2014 16:02:40 -0400 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:49378) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjvvU-0001ub-73 for qemu-devel@nongnu.org; Thu, 30 Oct 2014 16:02:32 -0400 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 30 Oct 2014 20:02:29 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9273E1B08049 for ; Thu, 30 Oct 2014 20:02:31 +0000 (GMT) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s9UK2R5x61145310 for ; Thu, 30 Oct 2014 20:02:27 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s9UK2R6g000460 for ; Thu, 30 Oct 2014 14:02:27 -0600 Message-ID: <54529952.8020000@de.ibm.com> Date: Thu, 30 Oct 2014 21:02:26 +0100 From: Christian Borntraeger MIME-Version: 1.0 References: <1414591622-5620-1-git-send-email-zodiac@ispras.ru> In-Reply-To: <1414591622-5620-1-git-send-email-zodiac@ispras.ru> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] hw/i386/acpi-build.c: Fix memory leak in acpi_build_tables_cleanup() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikita Belov , qemu-devel@nongnu.org Cc: Paolo Bonzini , "Michael S. Tsirkin" , Vasily Efimov , Kirill Batuzov Am 29.10.2014 15:07, schrieb Nikita Belov: > There are three ACPI tables: 'linker_data', 'rsdp' and 'table_data'. They are > used differently. Two of them are being copied before using and only the copy > is used later. But the third is used directly. Because of that we need to free > two tables completely and delete only wrapper for the third one. > > Valgrind output: > ==23931== 131,072 bytes in 1 blocks are definitely lost in loss record 7,729 of 7,734 > ==23931== at 0x4C2CE8E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) > ==23931== by 0x2EA920: realloc_and_trace (vl.c:2811) > ==23931== by 0x509E6AE: g_realloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0) > ==23931== by 0x506DB32: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0) > ==23931== by 0x506E463: g_array_set_size (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0) > ==23931== by 0x256A4F: acpi_align_size (acpi-build.c:487) > ==23931== by 0x259F92: acpi_build (acpi-build.c:1601) > ==23931== by 0x25A212: acpi_setup (acpi-build.c:1682) > ==23931== by 0x24F346: pc_guest_info_machine_done (pc.c:1110) > ==23931== by 0x55FAAB: notifier_list_notify (notify.c:39) > ==23931== by 0x2EA704: qemu_run_machine_init_done_notifiers (vl.c:2759) > ==23931== by 0x2EEC3C: main (vl.c:4504) > > Signed-off-by: Nikita Belov Acked-by: Christian Borntraeger I found the same issue during the preparation of my KVM forum presentation and came to the same conclusion. CC Paolo (as x86 maintainer.) > --- > hw/i386/acpi-build.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index 00be4bb..c1778db 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -1498,11 +1498,9 @@ static inline void acpi_build_tables_init(AcpiBuildTables *tables) > static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre) > { > void *linker_data = bios_linker_loader_cleanup(tables->linker); > - if (mfre) { > - g_free(linker_data); > - } > + g_free(linker_data); > g_array_free(tables->rsdp, mfre); > - g_array_free(tables->table_data, mfre); > + g_array_free(tables->table_data, true); > } > > typedef > -- > 1.9.0.msysgit.0 >