libvirt/SOURCES/libvirt-qemu-Don-t-take-double-pointer-in-qemuDomainSecretInfoFree.patch
2021-09-10 11:58:15 +00:00

162 lines
5.6 KiB
Diff

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