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: Kirill Batuzov
Subject: Re: [Qemu-devel] [PATCH] hw/arm/realview.c: Fix memory leak in realview_init()
Date: Fri, 31 Oct 2014 15:32:50 +0300 (MSK)
User-agent: Alpine 2.02 (DEB 1266 2009-07-14)

On Fri, 31 Oct 2014, Peter Maydell wrote:

> On 31 October 2014 10:42, Nikita Belov <address@hidden> wrote:
> > On 2014-10-29 19:03, Peter Maydell wrote:
> >> We leak all of the MemoryRegions we allocate here, because we
> >> don't have a persistent state struct to keep them in. This
> >> doesn't really matter much because they're generally needed
> >> for the lifetime of the QEMU process anyway, and we only call
> >> board init functions once. So why worry about ram_lo in
> >> particular (and why this board in particular)?
> 
> > Indeed, generally we need memory regions for the lifetime of QEMU, but
> > 'mem_lo'
> > is different. It may not be used at all. We use 'ram_lo' only when a
> > condition is
> > true, in other case we will lose this pointer. Because of that if the
> > condition is
> > false we have memory leak immediately (not when QEMU exits).
> 
> No, ram_lo is exactly the same as the other memory regions
> here: we allocate it in this function, we don't keep any
> kind of pointer to it after we leave this function,

This is not true. We keep pointer to the memory region when we add it as
a subregion of another region. As long as we have a pointer to a root
region(s) we have a pointer to any other used region. Which is not the
case for unused ones.

Actually it is impossible to use a dinamically allocated piece of
memory and not to have a pointer to it at the same time.

> and
> we rely on it being freed on QEMU exit. The fact that we
> don't happen to use ram_lo in all cases is irrelevant.
>

-- 
Kirill



reply via email to

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