[libvirt PATCH 2/7] qemusecuritytest: Unlock virDomainObj before disposal

Tim Wiederhake twiederh at redhat.com
Thu Aug 5 13:08:46 UTC 2021


virDomainObj contains a mutex. Destroying a locked mutex results in
undefined behavior.

Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 tests/qemusecuritytest.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/qemusecuritytest.c b/tests/qemusecuritytest.c
index a7e87fdf8f..b14da08f1b 100644
--- a/tests/qemusecuritytest.c
+++ b/tests/qemusecuritytest.c
@@ -114,7 +114,7 @@ testDomain(const void *opaque)
     /* Mocking is enabled only when this env variable is set.
      * See mock code for explanation. */
     if (g_setenv(ENVVAR, "1", FALSE) == FALSE)
-        return -1;
+        goto cleanup;
 
     if (qemuSecuritySetAllLabel(data->driver, vm, NULL, false) < 0)
         goto cleanup;
@@ -126,6 +126,7 @@ testDomain(const void *opaque)
 
     ret = 0;
  cleanup:
+    virObjectUnlock(vm);
     g_unsetenv(ENVVAR);
     freePaths();
     return ret;
-- 
2.31.1




More information about the libvir-list mailing list