The qemu_init_irq() method initializes an IRQ object, but
the caller is responsible for eventually freeing it by calling
qemu_free_irq(). Generally we don't remember to do this.
Implement a harder-to-misuse API, qemu_init_irq_child(). This is to
qemu_init_irq() what object_initialize_child() is to
object_initialize(): it both initializes the object and makes it a
child of the parent QOM object. If you use this in a device's
realize or instance_init method then the IRQ will be automatically
freed when the device is destroyed.
Patch 1 is the new function; patches 2 and 3 are bugfixes for
leaks that show up with ASAN in device-introspect-test (which
does an instance_init -> deinit on every device).
The other callers of qemu_init_irq() could also be changed over
to use this new function, but they don't cause in-practice
leaks because they call the function in realize, and they
are devices which are never unrealized.
thanks
-- PMM
Peter Maydell (3):
hw/irq: New qemu_init_irq_child() function
hw/char/serial-pci-multi: Use qemu_init_irq_child() to avoid leak
hw/ide/ich.c: Use qemu_init_irq_child() to avoid memory leak
include/hw/irq.h | 23 ++++++++++++++++++++++-
hw/char/serial-pci-multi.c | 4 +++-
hw/core/irq.c | 8 ++++++++
hw/ide/ich.c | 3 ++-
4 files changed, 35 insertions(+), 3 deletions(-)
--
2.43.0