On 31 October 2014 10:42, Nikita Belov <zod...@ispras.ru> 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, 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. This isn't any more of a bug than the similar code for any of the other memory regions in this board or in many of our other boards. I don't think there's any point changing this code unless you want to refactor the board so it is a proper subclass of MachineState with its own state structure to hold the MemoryRegion pointers in. thanks -- PMM