qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] hw/arm/realview.c: Fix memory leak in realview_


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] hw/arm/realview.c: Fix memory leak in realview_init()
Date: Thu, 20 Nov 2014 12:00:14 +0000

On 20 November 2014 11:53, Kirill Batuzov <address@hidden> wrote:
> I'm surprised that this small patch caused so much controversy. It seems
> very simple and straightforward to me.
>
> This patch fixes a memory leak. The fact that it indeed was a memory
> leak is indicated by Valgrind output (Memcheck's false-positives are
> extremely rare unless you do some really nasty things with your pointers).
> It can be verified manually too: there are only 4 occurrences of 'ram_lo'
> in realview.c.

It's in exactly the same situation as the other blocks of memory
like ram_hi in that file: we allocate it and then don't care about
freeing it, because we don't happen to have a board state struct.
The correct fix if you care about this kind of thing would be
to have a board state struct which had MemoryRegion fields (not
MemoryRegion* fields). We have lots of bits of memory that we
allocate once on startup and then don't care about freeing.

I'll probably put it in, because it's not very harmful. It just
doesn't seem to me very useful to merely silence the warning
rather than actually fixing the underlying thing that the
warning is telling you about.

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]