hw/arm: Don't allocate separate MemoryRegions in stm32 SoC realize

In the realize methods of the stm32f100 and stm32f205 SoC objects, we
call g_new() to create new MemoryRegion objects for the sram, flash,
and flash_alias.  This is unnecessary (and leaves open the
possibility of leaking the allocations if we exit from realize with
an error).  Make these MemoryRegions member fields of the device
state struct instead, as stm32f405 already does.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alexandre Iooss <erdnaxe@crans.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Luc Michel <luc@lmichel.fr>
Message-id: 20210812093356.1946-11-peter.maydell@linaro.org
This commit is contained in:
Peter Maydell 2021-08-12 10:33:41 +01:00
parent 99abcbc760
commit cabc613f78
4 changed files with 22 additions and 20 deletions

View file

@ -63,6 +63,10 @@ struct STM32F205State {
STM32F2XXSPIState spi[STM_NUM_SPIS];
qemu_or_irq *adc_irqs;
MemoryRegion sram;
MemoryRegion flash;
MemoryRegion flash_alias;
};
#endif