qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] vhost-user-test: fix a memory leak
@ 2019-12-20  1:26 pannengyuan
  2020-01-10 14:07 ` Thomas Huth
  0 siblings, 1 reply; 8+ messages in thread
From: pannengyuan @ 2019-12-20  1:26 UTC (permalink / raw)
  To: thuth, lvivier, pbonzini; +Cc: Pan Nengyuan, zhang.zhanghailiang, qemu-devel

From: Pan Nengyuan <pannengyuan@huawei.com>

Spotted by ASAN.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
---
Changes V2 to V1:
- use a "goto cleanup", instead of duplicating the "free" functions.
- free "dest_cmdline" at the end.
---
 tests/vhost-user-test.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 91ea373..dcb8617 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -717,7 +717,7 @@ static void test_migrate(void *obj, void *arg, QGuestAllocator *alloc)
     guint64 size;
 
     if (!wait_for_fds(s)) {
-        return;
+        goto cleanup;
     }
 
     size = get_log_size(s);
@@ -776,8 +776,11 @@ static void test_migrate(void *obj, void *arg, QGuestAllocator *alloc)
     g_source_unref(source);
 
     qtest_quit(to);
+
+ cleanup:
     test_server_free(dest);
     g_free(uri);
+    g_string_free(dest_cmdline, true);
 }
 
 static void wait_for_rings_started(TestServer *s, size_t count)
-- 
2.7.2.windows.1




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

end of thread, other threads:[~2020-01-17  0:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20  1:26 [PATCH V2] vhost-user-test: fix a memory leak pannengyuan
2020-01-10 14:07 ` Thomas Huth
2020-01-12 10:39   ` Thomas Huth
2020-01-13  2:32     ` Pan Nengyuan
2020-01-15  3:10       ` Pan Nengyuan
2020-01-15  9:13         ` Thomas Huth
2020-01-16 13:29           ` Thomas Huth
2020-01-17  0:44             ` Pan Nengyuan

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).