On 9/3/26 10:51, Peter Maydell wrote:
The sifive_e_aon watchdog creates a timer with timer_new_ns() in its instance_init method, but does not free it in instance_finalize. This means that QMP introspection of the device leaks it:Direct leak of 48 byte in 1 object allocated from: #0 in calloc #1 in g_malloc0 #2 in timer_new_full /home/pm215/qemu/include/qemu/timer.h:520:21 #3 in timer_new /home/pm215/qemu/include/qemu/timer.h:543:12 #4 in timer_new_ns /home/pm215/qemu/include/qemu/timer.h:563:12 #5 in sifive_e_aon_init /home/pm215/qemu/build/san/../../hw/misc/sifive_e_aon.c:286:21 #6 in object_initialize_with_type /home/pm215/qemu/build/san/../../qom/object.c:570:5 #7 in object_initialize /home/pm215/qemu/build/san/../../qom/object.c:578:5 #8 in object_initialize_child_with_propsv /home/pm215/qemu/build/san/../../qom/object.c:608:5 #9 in object_initialize_child_with_props /home/pm215/qemu/build/san/../../qom/object.c:591:10 #10 in object_initialize_child_internal /home/pm215/qemu/build/san/../../qom/object.c:645:5 #11 in object_initialize_with_type /home/pm215/qemu/build/san/../../qom/object.c:570:5 #12 in object_new_with_type /home/pm215/qemu/build/san/../../qom/object.c:774:5 #13 in qmp_device_list_properties /home/pm215/qemu/build/san/../../qom/qom-qmp-cmds.c:206:11 Allocating a separate QEMUTimer with timer_new() is not the preferred interface (per the comments in include/qemu/timer.h); switch to an inline struct initialized with timer_init(), which we can clean up with timer_del() in finalize. Signed-off-by: Peter Maydell <[email protected]> --- Incidentally I notice that this device doesn't have vmstate support, which is unfortunate -- devices really ought to either support it or else install a migration-blocker explaining why they can't. hw/misc/sifive_e_aon.c | 16 ++++++++++++---- include/hw/misc/sifive_e_aon.h | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-)
Patch queued via hw-misc, thanks.
