[PULL 12/20] tests/qtest/tpm-util.c: Free memory with correct free function

Thomas Huth posted 20 patches 4 years, 9 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Thomas Huth <thuth@redhat.com>, Li-Wen Hsu <lwhsu@freebsd.org>, Willian Rampazzo <willianr@redhat.com>, Tyrone Ting <kfting@nuvoton.com>, "Alex Bennée" <alex.bennee@linaro.org>, Juan Quintela <quintela@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Wainer dos Santos Moschetta <wainersm@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Havard Skinnemoen <hskinnemoen@google.com>, Ed Maste <emaste@freebsd.org>, Yonggang Luo <luoyonggang@gmail.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>
[PULL 12/20] tests/qtest/tpm-util.c: Free memory with correct free function
Posted by Thomas Huth 4 years, 9 months ago
From: Peter Maydell <peter.maydell@linaro.org>

tpm_util_migration_start_qemu() allocates memory with g_strdup_printf()
but frees it with free() rather than g_free(), which provokes Coverity
complaints (CID 1432379, 1432350). Use the correct free function.

Fixes: Coverity CID 1432379, CID 1432350
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210503165525.26221-2-peter.maydell@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/tpm-util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c
index b70cc32d60..3a40ff3f96 100644
--- a/tests/qtest/tpm-util.c
+++ b/tests/qtest/tpm-util.c
@@ -289,6 +289,6 @@ void tpm_util_migration_start_qemu(QTestState **src_qemu,
 
     *dst_qemu = qtest_init(dst_qemu_args);
 
-    free(src_qemu_args);
-    free(dst_qemu_args);
+    g_free(src_qemu_args);
+    g_free(dst_qemu_args);
 }
-- 
2.27.0