From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbFF3-0008Dy-1k for qemu-devel@nongnu.org; Wed, 21 Nov 2012 13:41:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TbFEx-0000UK-AZ for qemu-devel@nongnu.org; Wed, 21 Nov 2012 13:41:44 -0500 Message-ID: <50AD205E.6070501@suse.de> Date: Wed, 21 Nov 2012 19:41:34 +0100 From: Alexander Graf MIME-Version: 1.0 References: <1353483485-17019-1-git-send-email-hong-hua.yin@freescale.com> <1353483485-17019-5-git-send-email-hong-hua.yin@freescale.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v5 4/4] free the memory malloced by load_at() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stuart Yoder Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Olivia Yin On 11/21/2012 07:39 PM, Stuart Yoder wrote: > On Wed, Nov 21, 2012 at 8:38 AM, Olivia Yin wrote: >> Signed-off-by: Olivia Yin >> --- >> hw/elf_ops.h | 2 ++ >> 1 files changed, 2 insertions(+), 0 deletions(-) >> >> diff --git a/hw/elf_ops.h b/hw/elf_ops.h >> index b346861..9c76a75 100644 >> --- a/hw/elf_ops.h >> +++ b/hw/elf_ops.h >> @@ -178,6 +178,8 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab, >> s->disas_strtab = str; >> s->next = syminfos; >> syminfos = s; >> + g_free(syms); >> + g_free(str); >> g_free(shdr_table); >> return 0; >> fail: > Olivia, as Alex pointed out there are references to syms and str in > the struct "s"....so you can't just free those I don't think. > > The problem that leaves us with is that on every reset when we call > load_elf() that we re-load and re-malloc space for the symbols. > > I think the solution may be to factor out the call to load_symbols() > from load_elf(). It looks like what load_symbols does in the end is > set the variable syminfos to point to the loaded symbol info. > > If you factor load_symbols() out then in load_elf_32/64() you would do > something like: > elf_phy_loader_32/64() > load_symbols_32/64(). > > We don't need to be reloading symbols on every reset. > > Alex, does that make sense? We can also mandate the caller of load_symbols to free the respective data :) Alex