when using valgrind to test the command "query memdev", I had found some memory leaks. the test result:
==13802== 4 bytes in 1 blocks are definitely lost in loss record 125 of 8,508 ==13802== at 0x4A08934: malloc (vg_replace_malloc.c:291) ==13802== by 0x4A08AA8: realloc (vg_replace_malloc.c:687) ==13802== by 0x64C5736: g_realloc (in /usr/lib64/libglib-2.0.so.0.3400.2) ==13802== by 0x64DE226: ??? (in /usr/lib64/libglib-2.0.so.0.3400.2) ==13802== by 0x64DE279: g_string_sized_new (in /usr/lib64/libglib-2.0.so.0.3400.2) ==13802== by 0x47CFBB: string_output_visitor_new (string-output-visitor.c:341) ==13802== by 0x3F456F: object_property_get_uint16List (object.c:970) ==13802== by 0x1E8764: query_memdev (numa.c:361) ==13802== by 0x3F3248: object_child_foreach (object.c:686) ==13802== by 0x1E9141: qmp_query_memdev (numa.c:389) ==13802== by 0x2D79A0: qmp_marshal_input_query_memdev (qmp-marshal.c:5057) ==13802== by 0x1DD7D7: handle_qmp_command (monitor.c:5038) ==15046== 48 (16 direct, 32 indirect) bytes in 1 blocks are definitely lost in loss record 4,722 of 8,549 ==15046== at 0x4A08934: malloc (vg_replace_malloc.c:291) ==15046== by 0x64C541D: ??? (in /usr/lib64/libglib-2.0.so.0.3400.2) ==15046== by 0x64C56E6: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.3400.2) ==15046== by 0x1E868C: query_memdev (numa.c:325) ==15046== by 0x3F3258: object_child_foreach (object.c:686) ==15046== by 0x1E9141: qmp_query_memdev (numa.c:389) ==15046== by 0x2DDFF3: hmp_info_memdev (hmp.c:1687) ==15046== by 0x1E4B08: handle_user_command (monitor.c:4119) ==15046== by 0x1E4E7A: monitor_command_cb (monitor.c:5156) ==15046== by 0x496056: readline_handle_byte (readline.c:391) ==15046== by 0x1E4BCE: monitor_read (monitor.c:5139) ==15046== by 0x2BCDEF: fd_chr_read (qemu-char.c:213) Chen Fan (3): query-memdev: fix potential memory leaks qom/object.c: fix string_output_get_string() memory leak hmp: fix MemdevList memory leak hmp.c | 15 ++++++++++----- numa.c | 6 +++++- qom/object.c | 11 ++++++++--- 3 files changed, 23 insertions(+), 9 deletions(-) -- 1.9.3