qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qmp: Fix memory leak in migrate_params_test_apply
@ 2019-08-27 11:16 Ying Fang
  2019-08-28  7:58 ` Stefano Garzarella
  0 siblings, 1 reply; 8+ messages in thread
From: Ying Fang @ 2019-08-27 11:16 UTC (permalink / raw)
  To: qemu-devel, quintela; +Cc: lcf.lichaofeng, Ying Fang, zhanghailiang, zhouyibo3

Address Sanitizer shows memory leak in migrate_params_test_apply
migration/migration.c:1253 and the stack is as bellow:

Direct leak of 45 byte(s) in 9 object(s) allocated from:
    #0 0xffffbd7fc1db in __interceptor_malloc (/lib64/libasan.so.4+0xd31db)
    #1 0xffffbd514163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163)
    #2 0xffffbd52f43b in g_strdup (/lib64/libglib-2.0.so.0+0x7243b)
    #3 0xaaaadfa4d623 in migrate_params_test_apply migration/migration.c:1253
    #4 0xaaaadfa4d623 in qmp_migrate_set_parameters migration/migration.c:1422
    #5 0xaaaadfa963f3 in hmp_migrate_set_parameter monitor/hmp-cmds.c:1867
    #6 0xaaaadfa8afe3 in handle_hmp_command monitor/hmp.c:1082
    #7 0xaaaadf479c57 in qmp_human_monitor_command monitor/misc.c:140
    #8 0xaaaadfadf87b in qmp_marshal_human_monitor_command qapi/qapi-commands-misc.c:1024
    #9 0xaaaadfc7797b in do_qmp_dispatch qapi/qmp-dispatch.c:131
    #10 0xaaaadfc7797b in qmp_dispatch qapi/qmp-dispatch.c:174
    #11 0xaaaadfa84fff in monitor_qmp_dispatch monitor/qmp.c:120
    #12 0xaaaadfa85bbf in monitor_qmp_bh_dispatcher monitor/qmp.c:209
    #13 0xaaaadfd2228f in aio_bh_call util/async.c:89
    #14 0xaaaadfd2228f in aio_bh_poll util/async.c:117
    #15 0xaaaadfd29bc3 in aio_dispatch util/aio-posix.c:459
    #16 0xaaaadfd21ff7 in aio_ctx_dispatch util/async.c:260
    #17 0xffffbd50e2f7 in g_main_context_dispatch (/lib64/libglib-2.0.so.0+0x512f7)
    #18 0xaaaadfd278d7 in glib_pollfds_poll util/main-loop.c:218
    #19 0xaaaadfd278d7 in os_host_main_loop_wait util/main-loop.c:241
    #20 0xaaaadfd278d7 in main_loop_wait util/main-loop.c:517
    #21 0xaaaadf67b5e7 in main_loop vl.c:1806
    #22 0xaaaadf15d453 in main vl.c:4488

Cc: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Ying Fang <fangying1@huawei.com>
---
 migration/migration.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/migration/migration.c b/migration/migration.c
index 8b9f2fe30a..d60dda2b9c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1250,11 +1250,13 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
 
     if (params->has_tls_creds) {
         assert(params->tls_creds->type == QTYPE_QSTRING);
+        g_free(dest->tls_creds);
         dest->tls_creds = g_strdup(params->tls_creds->u.s);
     }
 
     if (params->has_tls_hostname) {
         assert(params->tls_hostname->type == QTYPE_QSTRING);
+        g_free(dest->tls_hostname);
         dest->tls_hostname = g_strdup(params->tls_hostname->u.s);
     }
 
-- 
2.19.1




^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH] qmp: Fix memory leak in migrate_params_test_apply
@ 2019-08-27  8:05 Ying Fang
  2019-08-27  8:30 ` no-reply
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Ying Fang @ 2019-08-27  8:05 UTC (permalink / raw)
  To: qemu-devel, dgilbert, quintela
  Cc: lcf.lichaofeng, Ying Fang, zhanghailiang, zhouyibo3

Address Sanitizer shows memory leak in migrate_params_test_apply
migration/migration.c:1253 and the stack is as bellow:

Direct leak of 45 byte(s) in 9 object(s) allocated from:
    #0 0xffffbd7fc1db in __interceptor_malloc (/lib64/libasan.so.4+0xd31db)
    #1 0xffffbd514163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163)
    #2 0xffffbd52f43b in g_strdup (/lib64/libglib-2.0.so.0+0x7243b)
    #3 0xaaaadfa4d623 in migrate_params_test_apply migration/migration.c:1253
    #4 0xaaaadfa4d623 in qmp_migrate_set_parameters migration/migration.c:1422
    #5 0xaaaadfa963f3 in hmp_migrate_set_parameter monitor/hmp-cmds.c:1867
    #6 0xaaaadfa8afe3 in handle_hmp_command monitor/hmp.c:1082
    #7 0xaaaadf479c57 in qmp_human_monitor_command monitor/misc.c:140
    #8 0xaaaadfadf87b in qmp_marshal_human_monitor_command qapi/qapi-commands-misc.c:1024
    #9 0xaaaadfc7797b in do_qmp_dispatch qapi/qmp-dispatch.c:131
    #10 0xaaaadfc7797b in qmp_dispatch qapi/qmp-dispatch.c:174
    #11 0xaaaadfa84fff in monitor_qmp_dispatch monitor/qmp.c:120
    #12 0xaaaadfa85bbf in monitor_qmp_bh_dispatcher monitor/qmp.c:209
    #13 0xaaaadfd2228f in aio_bh_call util/async.c:89
    #14 0xaaaadfd2228f in aio_bh_poll util/async.c:117
    #15 0xaaaadfd29bc3 in aio_dispatch util/aio-posix.c:459
    #16 0xaaaadfd21ff7 in aio_ctx_dispatch util/async.c:260
    #17 0xffffbd50e2f7 in g_main_context_dispatch (/lib64/libglib-2.0.so.0+0x512f7)
    #18 0xaaaadfd278d7 in glib_pollfds_poll util/main-loop.c:218
    #19 0xaaaadfd278d7 in os_host_main_loop_wait util/main-loop.c:241
    #20 0xaaaadfd278d7 in main_loop_wait util/main-loop.c:517
    #21 0xaaaadf67b5e7 in main_loop vl.c:1806
    #22 0xaaaadf15d453 in main vl.c:4488

Cc: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Ying Fang <fangying1@huawei.com>
---
 migration/migration.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/migration/migration.c b/migration/migration.c
index 8b9f2fe30a..05e44ff7cc 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1250,11 +1250,17 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
 
     if (params->has_tls_creds) {
         assert(params->tls_creds->type == QTYPE_QSTRING);
+        if (dest->tls_creds) {
+            g_free(dest->tls_creds);
+        }
         dest->tls_creds = g_strdup(params->tls_creds->u.s);
     }
 
     if (params->has_tls_hostname) {
         assert(params->tls_hostname->type == QTYPE_QSTRING);
+        if (dest->tls_hostname) {
+            g_free(dest->tls_hostname);
+        }
         dest->tls_hostname = g_strdup(params->tls_hostname->u.s);
     }
 
-- 
2.19.1




^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-09-04  7:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 11:16 [Qemu-devel] [PATCH] qmp: Fix memory leak in migrate_params_test_apply Ying Fang
2019-08-28  7:58 ` Stefano Garzarella
  -- strict thread matches above, loose matches on Subject: below --
2019-08-27  8:05 Ying Fang
2019-08-27  8:30 ` no-reply
2019-08-27  8:38 ` Li Qiang
2019-08-27  9:13   ` fangying
2019-09-03 16:46 ` Dr. David Alan Gilbert
2019-09-04  7:24   ` fangying

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).