You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/hw/arm
Peter Maydell 7e52554c29 hw/arm/boot: Correctly free the MemoryDeviceInfoList
When running the bios-tables-test under ASAN we see leaks like this:

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x5bc58579b00d in calloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qemu-system-aarch64+0x250400d) (BuildId: 2e27b63dc9ac45f522ced40a17c2a60cc32f1d38)
    #1 0x7b4ad90337b1 in g_malloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x637b1) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #2 0x5bc5861826db in qmp_memory_device_list /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/mem/memory-device.c:307:34
    #3 0x5bc587a9edb6 in arm_load_dtb /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/arm/boot.c:656:15

Indirect leak of 28 byte(s) in 2 object(s) allocated from:
    #0 0x5bc58579ae23 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qemu-system-aarch64+0x2503e23) (BuildId: 2e27b63dc9ac45f522ced40a17c2a60cc32f1d38)
    #1 0x7b4ad6c8f947 in __vasprintf_internal libio/vasprintf.c:116:16
    #2 0x7b4ad9080a52 in g_vasprintf (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0xb0a52) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #3 0x7b4ad90515e4 in g_strdup_vprintf (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x815e4) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #4 0x7b4ad9051940 in g_strdup_printf (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x81940) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #5 0x5bc5885eb739 in object_get_canonical_path /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../qom/object.c:2123:19
    #6 0x5bc58618dca8 in pc_dimm_md_fill_device_info /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/mem/pc-dimm.c:268:18
    #7 0x5bc586182792 in qmp_memory_device_list /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/mem/memory-device.c:310:9

This happens because we declared the MemoryDeviceInfoList *md_list
with g_autofree, which will free the direct memory with g_free() but
doesn't free all the other data structures referenced by it.  Instead
what we want is to declare the pointer with g_autoptr(), which will
automatically call the qapi_free_MemoryDeviceInfoList() cleanup
function when the variable goes out of scope.

Fixes: 36bc78aca8 ("hw/arm: add static NVDIMMs in device tree")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250901102214.3748011-1-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6 days ago
..
Kconfig hw/arm/virt-acpi-build: Let non hotplug ports support static acpi-index 2 months ago
allwinner-a10.c qom: Have class_init() take a const data argument 5 months ago
allwinner-h3.c qom: Have class_init() take a const data argument 5 months ago
allwinner-r40.c qemu: Declare all load/store helper in 'qemu/bswap.h' 2 months ago
armsse.c qom: Make InterfaceInfo[] uses const 5 months ago
armv7m.c qom: Have class_init() take a const data argument 5 months ago
aspeed.c hw/arm/aspeed: Add GB200 BMC target 2 months ago
aspeed_ast10x0.c qom: Have class_init() take a const data argument 5 months ago
aspeed_ast27x0-fc.c hw/arm/aspeed_ast27x0-fc: Map ca35 memory into system memory 4 months ago
aspeed_ast27x0-ssp.c hw/arm/aspeed_ast27x0-ssp: Introduce AST27x0 A1 SSP SoC 4 months ago
aspeed_ast27x0-tsp.c hw/arm/aspeed_ast27x0-tsp: Introduce AST27x0 A1 TSP SoC 4 months ago
aspeed_ast27x0.c hw/arm/aspeed_ast27x0: Fix unimplemented region overlap with vbootrom 4 months ago
aspeed_ast2400.c qom: Have class_init() take a const data argument 5 months ago
aspeed_ast2600.c qom: Have class_init() take a const data argument 5 months ago
aspeed_eeprom.c hw/arm/aspeed: Add GB200 BMC target 2 months ago
aspeed_eeprom.h hw/arm/aspeed: Add GB200 BMC target 2 months ago
aspeed_soc_common.c qom: Have class_init() take a const data argument 5 months ago
b-l475e-iot01a.c qom: Have class_init() take a const data argument 5 months ago
bananapi_m2u.c include/system: Move exec/address-spaces.h to system/address-spaces.h 5 months ago
bcm2835_peripherals.c qom: Have class_init() take a const data argument 5 months ago
bcm2836.c qom: Have class_init() take a const data argument 5 months ago
bcm2838.c qom: Have class_init() take a const data argument 5 months ago
bcm2838_peripherals.c qom: Have class_init() take a const data argument 5 months ago
boot.c hw/arm/boot: Correctly free the MemoryDeviceInfoList 6 days ago
collie.c qom: Have class_init() take a const data argument 5 months ago
cubieboard.c hw/boards: Rename no_sdcard -> auto_create_sdcard 7 months ago
digic.c qom: Have class_init() take a const data argument 5 months ago
digic_boards.c hw/arm/digic_boards: prepare compilation unit to be common 5 months ago
exynos4_boards.c qom: Have class_init() take a const data argument 5 months ago
exynos4210.c qom: Have class_init() take a const data argument 5 months ago
fby35.c hw/arm/fby35: Map BMC memory into system memory 4 months ago
fsl-imx6.c qom: Have class_init() take a const data argument 5 months ago
fsl-imx6ul.c qom: Have class_init() take a const data argument 5 months ago
fsl-imx7.c qom: Have class_init() take a const data argument 5 months ago
fsl-imx8mp.c hw/arm/fsl-imx8mp: Wire VIRQ and VFIQ 2 months ago
fsl-imx25.c qom: Have class_init() take a const data argument 5 months ago
fsl-imx31.c qom: Have class_init() take a const data argument 5 months ago
highbank.c hw/arm/highbank: Mark the "highbank" and the "midway" machine as deprecated 2 months ago
imx8mp-evk.c include/system: Move exec/address-spaces.h to system/address-spaces.h 5 months ago
imx25_pdk.c hw/boards: Rename no_sdcard -> auto_create_sdcard 7 months ago
integratorcp.c qom: Have class_init() take a const data argument 5 months ago
kzm.c include/system: Move exec/address-spaces.h to system/address-spaces.h 5 months ago
max78000_soc.c MAX78000: Add AES to SOC 2 months ago
max78000fthr.c MAX78000: Add MAX78000FTHR Machine 2 months ago
mcimx6ul-evk.c hw/boards: Rename no_sdcard -> auto_create_sdcard 7 months ago
mcimx7d-sabre.c hw/boards: Rename no_sdcard -> auto_create_sdcard 7 months ago
meson.build MAX78000: Add MAX78000FTHR Machine 2 months ago
microbit.c qom: Have class_init() take a const data argument 5 months ago
mps2-tz.c qom: Make InterfaceInfo[] uses const 5 months ago
mps2.c hw/arm/mps2: Configure the AN500 CPU with 16 MPU regions 3 months ago
mps3r.c qom: Have class_init() take a const data argument 5 months ago
msf2-soc.c qom: Have class_init() take a const data argument 5 months ago
msf2-som.c include/system: Move exec/address-spaces.h to system/address-spaces.h 5 months ago
musca.c qom: Have class_init() take a const data argument 5 months ago
musicpal.c qom: Have class_init() take a const data argument 5 months ago
netduino2.c hw/arm: Remove all invalid uses of auto_create_sdcard=true 7 months ago
netduinoplus2.c hw/arm: Remove all invalid uses of auto_create_sdcard=true 7 months ago
npcm7xx.c qemu: Declare all load/store helper in 'qemu/bswap.h' 2 months ago
npcm7xx_boards.c qom: Have class_init() take a const data argument 5 months ago
npcm8xx.c hw/arm: Add missing psci_conduit to NPCM8XX SoC boot info 3 months ago
npcm8xx_boards.c hw/arm/npcm8xx_boards: Correct valid_cpu_types setting of NPCM8XX SoC 4 months ago
nrf51_soc.c qom: Have class_init() take a const data argument 5 months ago
olimex-stm32-h405.c hw/arm: Remove all invalid uses of auto_create_sdcard=true 7 months ago
omap1.c hw/arm: Replace TABs for spaces in OMAP board and device code 4 months ago
omap_sx1.c hw/arm: Replace TABs for spaces in OMAP board and device code 4 months ago
orangepi.c include/system: Move exec/address-spaces.h to system/address-spaces.h 5 months ago
raspi.c qom: Have class_init() take a const data argument 5 months ago
raspi4b.c qom: Have class_init() take a const data argument 5 months ago
realview.c qom: Have class_init() take a const data argument 5 months ago
sabrelite.c hw/boards: Rename no_sdcard -> auto_create_sdcard 7 months ago
sbsa-ref.c hw/arm/sbsa-ref: Tidy up use of RAMLIMIT_GB definition 2 months ago
smmu-common.c hw/arm/smmu-common: Avoid using inlined functions with external linkage 2 months ago
smmu-internal.h hw/arm/smmu: Introduce smmu_configs_inv_sid_range() helper 6 months ago
smmuv3-internal.h hw/arm/smmuv3: Assert input to oas2bits() is valid 1 year ago
smmuv3.c qom: Have class_init() take a const data argument 5 months ago
stellaris.c qom: Have class_init() take a const data argument 5 months ago
stm32f100_soc.c qom: Have class_init() take a const data argument 5 months ago
stm32f205_soc.c hw/arm/stm32f205_soc: Don't leak TYPE_OR_IRQ objects 1 week ago
stm32f405_soc.c qom: Have class_init() take a const data argument 5 months ago
stm32l4x5_soc.c qom: Have class_init() take a const data argument 5 months ago
stm32vldiscovery.c hw/arm: Remove all invalid uses of auto_create_sdcard=true 7 months ago
strongarm.c qom: Have class_init() take a const data argument 5 months ago
strongarm.h include/system: Move exec/memory.h to system/memory.h 5 months ago
trace-events hw/arm/smmu: Introduce smmu_configs_inv_sid_range() helper 6 months ago
trace.h trace: switch position of headers to what Meson requires 5 years ago
versatilepb.c qom: Have class_init() take a const data argument 5 months ago
vexpress.c qom: Have class_init() take a const data argument 5 months ago
virt-acpi-build.c hw/arm/virt-acpi-build: Modify the DSDT ACPI table to enable ACPI PCI hotplug 2 months ago
virt.c hw/arm/virt: Include 'system/system.h' 6 days ago
xen-pvh.c hw/arm/xen-pvh: Remove unnecessary 'hw/xen/arch_hvm.h' header 2 months ago
xen-stubs.c cleanup: Drop pointless return at end of function 5 months ago
xilinx_zynq.c qom: Have class_init() take a const data argument 5 months ago
xlnx-versal-virt.c qom: Have class_init() take a const data argument 5 months ago
xlnx-versal.c qom: Have class_init() take a const data argument 5 months ago
xlnx-zcu102.c qom: Have class_init() take a const data argument 5 months ago
xlnx-zynqmp.c qom: Have class_init() take a const data argument 5 months ago