[PATCH] tests: Don't leak cpu defs

Michal Privoznik posted 1 patch 2 years, 8 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/a4592e0e0b0e29361b8d8cbababa13f41fa10c7f.1628155192.git.mprivozn@redhat.com
tests/testutilsqemu.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] tests: Don't leak cpu defs
Posted by Michal Privoznik 2 years, 8 months ago
There are cpu definitions that are allocated in
qemuTestDriverInit() but are missing corresponding
virCPUDefFree() call in qemuTestDriverFree(). It's safe to call
the free function because the definitions contain a refcounter
and thus even if they were still in use the refcounter would be
just decreased.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tests/testutilsqemu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index fab676c070..9a0666724a 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -332,6 +332,11 @@ void qemuTestDriverFree(virQEMUDriver *driver)
     virObjectUnref(driver->caps);
     virObjectUnref(driver->config);
     virObjectUnref(driver->securityManager);
+
+    virCPUDefFree(cpuDefault);
+    virCPUDefFree(cpuHaswell);
+    virCPUDefFree(cpuPower8);
+    virCPUDefFree(cpuPower9);
 }
 
 int qemuTestCapsCacheInsert(virFileCache *cache,
-- 
2.31.1

Re: [PATCH] tests: Don't leak cpu defs
Posted by Jano Tomko 2 years, 8 months ago
On a %A in %Y, Michal Privoznik wrote:
> There are cpu definitions that are allocated in
> qemuTestDriverInit() but are missing corresponding
> virCPUDefFree() call in qemuTestDriverFree(). It's safe to call
> the free function because the definitions contain a refcounter
> and thus even if they were still in use the refcounter would be
> just decreased.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  tests/testutilsqemu.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano