render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From bcc3726dae87335a533565c6d679434fa69fe75e Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <bcc3726dae87335a533565c6d679434fa69fe75e@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Mon, 16 Mar 2020 22:11:41 +0100
a41c76
Subject: [PATCH] qemu: Don't take double pointer in qemuDomainSecretInfoFree
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Using a double pointer prevents the function from being used as the
a41c76
automatic cleanup function for the given type.
a41c76
a41c76
Remove the double pointer use by replacing the calls with
a41c76
g_clear_pointer which ensures that the pointer is cleared.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit 38bc76bcc1e1bccb7f3265e15b60b0f6f8fe6dfa)
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
a41c76
Message-Id: <56ebeda94754aab81a682202f26c1dc158ac063a.1584391726.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_domain.c           | 30 +++++++++++++-----------------
a41c76
 src/qemu/qemu_domain.h           |  2 +-
a41c76
 src/qemu/qemu_migration_params.c |  2 +-
a41c76
 3 files changed, 15 insertions(+), 19 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
a41c76
index 14bab896bc..b77488026a 100644
a41c76
--- a/src/qemu/qemu_domain.c
a41c76
+++ b/src/qemu/qemu_domain.c
a41c76
@@ -1106,14 +1106,10 @@ qemuDomainSecretInfoClear(qemuDomainSecretInfoPtr secinfo,
a41c76
 
a41c76
 
a41c76
 void
a41c76
-qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr *secinfo)
a41c76
+qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr secinfo)
a41c76
 {
a41c76
-    if (!*secinfo)
a41c76
-        return;
a41c76
-
a41c76
-    qemuDomainSecretInfoClear(*secinfo, false);
a41c76
-
a41c76
-    VIR_FREE(*secinfo);
a41c76
+    qemuDomainSecretInfoClear(secinfo, false);
a41c76
+    g_free(secinfo);
a41c76
 }
a41c76
 
a41c76
 
a41c76
@@ -1203,8 +1199,8 @@ qemuDomainStorageSourcePrivateDispose(void *obj)
a41c76
 {
a41c76
     qemuDomainStorageSourcePrivatePtr priv = obj;
a41c76
 
a41c76
-    qemuDomainSecretInfoFree(&priv->secinfo);
a41c76
-    qemuDomainSecretInfoFree(&priv->encinfo);
a41c76
+    g_clear_pointer(&priv->secinfo, qemuDomainSecretInfoFree);
a41c76
+    g_clear_pointer(&priv->encinfo, qemuDomainSecretInfoFree);
a41c76
 }
a41c76
 
a41c76
 
a41c76
@@ -1283,7 +1279,7 @@ qemuDomainChrSourcePrivateDispose(void *obj)
a41c76
 {
a41c76
     qemuDomainChrSourcePrivatePtr priv = obj;
a41c76
 
a41c76
-    qemuDomainSecretInfoFree(&priv->secinfo);
a41c76
+    g_clear_pointer(&priv->secinfo, qemuDomainSecretInfoFree);
a41c76
 }
a41c76
 
a41c76
 
a41c76
@@ -1362,7 +1358,7 @@ qemuDomainGraphicsPrivateDispose(void *obj)
a41c76
     qemuDomainGraphicsPrivatePtr priv = obj;
a41c76
 
a41c76
     VIR_FREE(priv->tlsAlias);
a41c76
-    qemuDomainSecretInfoFree(&priv->secinfo);
a41c76
+    g_clear_pointer(&priv->secinfo, qemuDomainSecretInfoFree);
a41c76
 }
a41c76
 
a41c76
 
a41c76
@@ -1642,7 +1638,7 @@ qemuDomainSecretInfoNewPlain(virSecretUsageType usageType,
a41c76
         return NULL;
a41c76
 
a41c76
     if (qemuDomainSecretPlainSetup(secinfo, usageType, username, lookupDef) < 0) {
a41c76
-        qemuDomainSecretInfoFree(&secinfo);
a41c76
+        g_clear_pointer(&secinfo, qemuDomainSecretInfoFree);
a41c76
         return NULL;
a41c76
     }
a41c76
 
a41c76
@@ -1685,7 +1681,7 @@ qemuDomainSecretInfoNew(qemuDomainObjPrivatePtr priv,
a41c76
 
a41c76
     if (qemuDomainSecretAESSetup(priv, secinfo, srcAlias, usageType, username,
a41c76
                                  lookupDef, isLuks) < 0) {
a41c76
-        qemuDomainSecretInfoFree(&secinfo);
a41c76
+        g_clear_pointer(&secinfo, qemuDomainSecretInfoFree);
a41c76
         return NULL;
a41c76
     }
a41c76
 
a41c76
@@ -1847,7 +1843,7 @@ qemuDomainSecretHostdevDestroy(virDomainHostdevDefPtr hostdev)
a41c76
         if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
a41c76
             srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(iscsisrc->src);
a41c76
             if (srcPriv && srcPriv->secinfo)
a41c76
-                qemuDomainSecretInfoFree(&srcPriv->secinfo);
a41c76
+                g_clear_pointer(&srcPriv->secinfo, qemuDomainSecretInfoFree);
a41c76
         }
a41c76
     }
a41c76
 }
a41c76
@@ -1891,7 +1887,7 @@ qemuDomainSecretChardevDestroy(virDomainChrSourceDefPtr dev)
a41c76
     if (!chrSourcePriv || !chrSourcePriv->secinfo)
a41c76
         return;
a41c76
 
a41c76
-    qemuDomainSecretInfoFree(&chrSourcePriv->secinfo);
a41c76
+    g_clear_pointer(&chrSourcePriv->secinfo, qemuDomainSecretInfoFree);
a41c76
 }
a41c76
 
a41c76
 
a41c76
@@ -1947,7 +1943,7 @@ qemuDomainSecretGraphicsDestroy(virDomainGraphicsDefPtr graphics)
a41c76
         return;
a41c76
 
a41c76
     VIR_FREE(gfxPriv->tlsAlias);
a41c76
-    qemuDomainSecretInfoFree(&gfxPriv->secinfo);
a41c76
+    g_clear_pointer(&gfxPriv->secinfo, qemuDomainSecretInfoFree);
a41c76
 }
a41c76
 
a41c76
 
a41c76
@@ -2307,7 +2303,7 @@ qemuDomainObjPrivateFree(void *data)
a41c76
     }
a41c76
     VIR_FREE(priv->cleanupCallbacks);
a41c76
 
a41c76
-    qemuDomainSecretInfoFree(&priv->migSecinfo);
a41c76
+    g_clear_pointer(&priv->migSecinfo, qemuDomainSecretInfoFree);
a41c76
     qemuDomainMasterKeyFree(priv);
a41c76
 
a41c76
     virHashFree(priv->blockjobs);
a41c76
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
a41c76
index 9d143b575d..89a967efd7 100644
a41c76
--- a/src/qemu/qemu_domain.h
a41c76
+++ b/src/qemu/qemu_domain.h
a41c76
@@ -1032,7 +1032,7 @@ void qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv);
a41c76
 
a41c76
 bool qemuDomainSupportsEncryptedSecret(qemuDomainObjPrivatePtr priv);
a41c76
 
a41c76
-void qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr *secinfo)
a41c76
+void qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr secinfo)
a41c76
     ATTRIBUTE_NONNULL(1);
a41c76
 
a41c76
 void qemuDomainSecretInfoDestroy(qemuDomainSecretInfoPtr secinfo);
a41c76
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
a41c76
index 45acf8cda2..f61796713f 100644
a41c76
--- a/src/qemu/qemu_migration_params.c
a41c76
+++ b/src/qemu/qemu_migration_params.c
a41c76
@@ -1090,7 +1090,7 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver,
a41c76
     secAlias = qemuDomainGetSecretAESAlias(QEMU_MIGRATION_TLS_ALIAS_BASE, false);
a41c76
 
a41c76
     qemuDomainDelTLSObjects(driver, vm, asyncJob, secAlias, tlsAlias);
a41c76
-    qemuDomainSecretInfoFree(&QEMU_DOMAIN_PRIVATE(vm)->migSecinfo);
a41c76
+    g_clear_pointer(&QEMU_DOMAIN_PRIVATE(vm)->migSecinfo, qemuDomainSecretInfoFree);
a41c76
 
a41c76
     VIR_FREE(tlsAlias);
a41c76
     VIR_FREE(secAlias);
a41c76
-- 
a41c76
2.25.1
a41c76