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/ide
Peter Maydell f905be6237 hw/ide/ich.c: Use qemu_init_irq_child() to avoid memory leak
The ICH9 PCI device uses qemu_init_irq() in its instance_init method,
but fails to clean it up in its uninit. This results in a leak,
detected by ASAN when running the device-introspect-test:

Direct leak of 96 byte(s) in 1 object(s) allocated from:
    #0 0x58f3b53ecde3 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/qem
u-system-arm+0x21f1de3) (BuildId: 8dcd38b1d76bd7bd44f905c38200f4cceafd7ca4)
    #1 0x72e446dd5b09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x62b09) (BuildId: 1
eb6131419edb83b2178b682829a6913cf682d75)
    #2 0x72e446db745a in g_hash_table_new_full (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4445a
) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75)
    #3 0x58f3b7c6fc67 in object_initialize_with_type /mnt/nvmedisk/linaro/qemu-from-laptop/qem
u/build/arm-asan/../../qom/object.c:568:23
    #4 0x58f3b7c6f670 in object_initialize /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/ar
m-asan/../../qom/object.c:578:5
    #5 0x58f3b7c6611b in qemu_init_irq /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/core/irq.c:48:5
    #6 0x58f3b5c6e931 in pci_ich9_ahci_init /mnt/nvmedisk/linaro/qemu-from-laptop/qemu/build/arm-asan/../../hw/ide/ich.c:117:5

We could call qemu_free_irq() in pci_ich9_uninit(), but
since we have a method of initializing the IRQ that doesn't
need manual freeing, use that instead: qemu_init_irq_child().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250821154053.2417090-4-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6 days ago
..
Kconfig hw/ide/ahci: Extract TYPE_SYSBUS_AHCI into dedicated file 9 months ago
ahci-allwinner.c qom: Have class_init() take a const data argument 5 months ago
ahci-internal.h hw/ide/ahci: Decouple from PCI 9 months ago
ahci-sysbus.c qom: Have class_init() take a const data argument 5 months ago
ahci.c include: Rename sysemu/ -> system/ 9 months ago
atapi.c include: Rename sysemu/ -> system/ 9 months ago
cf.c qom: Have class_init() take a const data argument 5 months ago
cmd646.c qom: Have class_init() take a const data argument 5 months ago
core.c dma: use current AioContext for dma_blk_io() 6 months ago
ich.c hw/ide/ich.c: Use qemu_init_irq_child() to avoid memory leak 6 days ago
ide-bus.c qom: Have class_init() take a const data argument 5 months ago
ide-dev.c qom: Have class_init() take a const data argument 5 months ago
ide-internal.h ide: collapse parameters to ide_init_drive 2 years ago
ioport.c hw/ide: Include 'ide-internal.h' from current path 2 years ago
isa.c qom: Have class_init() take a const data argument 5 months ago
macio.c qom: Have class_init() take a const data argument 5 months ago
meson.build hw/ide/ahci: Extract TYPE_SYSBUS_AHCI into dedicated file 9 months ago
mmio.c qom: Have class_init() take a const data argument 5 months ago
pci.c qom: Make InterfaceInfo[] uses const 5 months ago
piix.c qom: Have class_init() take a const data argument 5 months ago
sii3112.c qom: Have class_init() take a const data argument 5 months ago
trace-events hw/ide: Rename ide_exec_cmd() -> ide_bus_exec_cmd() 3 years ago
trace.h trace: switch position of headers to what Meson requires 5 years ago
via.c qom: Have class_init() take a const data argument 5 months ago