From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: "Alex Bennée" <alex.bennee@linaro.org>
Subject: [PULL 3/4] tests/qtest/vhost-user-test: Fix memory leaks
Date: Fri, 17 Jan 2020 12:07:57 +0100 [thread overview]
Message-ID: <20200117110758.1995-4-thuth@redhat.com> (raw)
In-Reply-To: <20200117110758.1995-1-thuth@redhat.com>
Do not allocate resources in case we return early, and make sure
to free dest_cmdline at the end.
Reported-by: Euler Robot <euler.robot@huawei.com>
Reported-by: Pan Nengyuan <pannengyuan@huawei.com>
Message-Id: <20200116140736.9498-1-thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/vhost-user-test.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c
index 2324b964ad..9ee0f1e4fd 100644
--- a/tests/qtest/vhost-user-test.c
+++ b/tests/qtest/vhost-user-test.c
@@ -707,9 +707,9 @@ static void test_read_guest_mem(void *obj, void *arg, QGuestAllocator *alloc)
static void test_migrate(void *obj, void *arg, QGuestAllocator *alloc)
{
TestServer *s = arg;
- TestServer *dest = test_server_new("dest");
- GString *dest_cmdline = g_string_new(qos_get_current_command_line());
- char *uri = g_strdup_printf("%s%s", "unix:", dest->mig_path);
+ TestServer *dest;
+ GString *dest_cmdline;
+ char *uri;
QTestState *to;
GSource *source;
QDict *rsp;
@@ -720,6 +720,10 @@ static void test_migrate(void *obj, void *arg, QGuestAllocator *alloc)
return;
}
+ dest = test_server_new("dest");
+ dest_cmdline = g_string_new(qos_get_current_command_line());
+ uri = g_strdup_printf("%s%s", "unix:", dest->mig_path);
+
size = get_log_size(s);
g_assert_cmpint(size, ==, (256 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));
@@ -778,6 +782,7 @@ static void test_migrate(void *obj, void *arg, QGuestAllocator *alloc)
qtest_quit(to);
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.18.1
next prev parent reply other threads:[~2020-01-17 11:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-17 11:07 [PULL 0/4] qtests and gitlab-CI Thomas Huth
2020-01-17 11:07 ` [PULL 1/4] tests: acpi: update path in rebuild-expected-aml Thomas Huth
2020-01-17 11:07 ` [PULL 2/4] migration-test: ppc64: fix FORTH test program Thomas Huth
2020-01-17 11:07 ` Thomas Huth [this message]
2020-01-17 11:07 ` [PULL 4/4] gitlab-ci.yml: Run tcg test with tci Thomas Huth
2020-01-17 16:46 ` [PULL 0/4] qtests and gitlab-CI no-reply
2020-01-17 17:27 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200117110758.1995-4-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).