hw/intc/apic: fix memory leak
commitafd1af1c9964335b1482693edbdd4b564c42e269
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 4 Mar 2024 22:39:02 +0000 (4 23:39 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 8 Mar 2024 14:51:22 +0000 (8 15:51 +0100)
tree64e4620d9a83ec46f17203bd7bde100fcd60f3ac
parenta9198b3132d81a6bfc9fdbf6f3d3a514c2864674
hw/intc/apic: fix memory leak

deliver_bitmask is allocated on the heap in apic_deliver(), but there
are many paths in the function that return before the corresponding
g_free() is reached.  Fix this by switching to g_autofree and, while at
it, also switch to g_new.  Do the same in apic_deliver_irq() as well
for consistency.

Fixes: b5ee0468e9d ("apic: add support for x2APIC mode", 2024-02-14)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/intc/apic.c