On 7/14/20 5:11 PM, Li Qiang wrote: > While 'make chekc', I got following error: > > root@ubuntu:~/qemu# ./tests/qtest/device-introspect-test > /x86_64/device/introspect/list: OK > /x86_64/device/introspect/list-fields: OK > /x86_64/device/introspect/none: > ================================================================= > ==53741==ERROR: LeakSanitizer: detected memory leaks > > Direct leak of 212 byte(s) in 20 object(s) allocated from: > #0 0x7f3b6319cb40 in __interceptor_malloc > (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) > #1 0x7f3b62805ab8 in g_malloc > (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x51ab8) > > SUMMARY: AddressSanitizer: 212 byte(s) leaked in 20 allocation(s). > tests/qtest/libqtest.c:166: kill_qemu() tried to terminate QEMU process but > encountered exit status 1 (expected 0) > Aborted (core dumped) > > This is because the 'info qom-tree' path has a memory leak and qemu > exit 1. The leak is in 'qom_composition_compare'. This patch fixes this. > > Fixes: e8c9e65816f("qom: Make "info qom-tree" show children sorted") > Signed-off-by: Li Qiang <liq...@163.com> > --- > qom/qom-hmp-cmds.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c > index 9ed8bb1c9f..3547d5ba4e 100644 > --- a/qom/qom-hmp-cmds.c > +++ b/qom/qom-hmp-cmds.c > @@ -96,8 +96,10 @@ static void print_qom_composition(Monitor *mon, Object > *obj, int indent); > > static int qom_composition_compare(const void *a, const void *b, void > *ignore) > { > - return g_strcmp0(a ? object_get_canonical_path_component(a) : NULL, > - b ? object_get_canonical_path_component(b) : NULL); > + g_autofree char *t1 = a ? object_get_canonical_path_component(a) : NULL; > + g_autofree char *t2 = b ? object_get_canonical_path_component(b) : NULL; > + > + return g_strcmp0(t1, t2); > } > > static int insert_qom_composition_child(Object *obj, void *opaque) >
Ah you won the race with Markus: https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg04740.html Reviewed-by: Philippe Mathieu-Daudé <phi...@redhat.com>