mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-31 18:15:25 +00:00
qemuDomainObjPrivateFree: Free @masterKey too
This one's a bit more complicated. In qemuProcessPrepareDomain() a master key for encrypting secret for ciphered disks is created. This object lives within qemuDomainObjPrivate object. It is freed in qemuProcessStop(), but if nobody calls it (for instance like our qemuxml2argvtest does), the key object leaks. ==17078== 32 bytes in 1 blocks are definitely lost in loss record 633 of 707 ==17078== at 0x4C2C070: calloc (vg_replace_malloc.c:623) ==17078== by 0xAD924DF: virAllocN (viralloc.c:191) ==17078== by 0x5050BA6: virCryptoGenerateRandom (qemuxml2argvmock.c:166) ==17078== by 0x453DC8: qemuDomainMasterKeyCreate (qemu_domain.c:678) ==17078== by 0x47A36B: qemuProcessPrepareDomain (qemu_process.c:4913) ==17078== by 0x47C728: qemuProcessCreatePretendCmd (qemu_process.c:5542) ==17078== by 0x433698: testCompareXMLToArgvFiles (qemuxml2argvtest.c:332) ==17078== by 0x4339AC: testCompareXMLToArgvHelper (qemuxml2argvtest.c:413) ==17078== by 0x446E7A: virTestRun (testutils.c:179) ==17078== by 0x445BD9: mymain (qemuxml2argvtest.c:2022) ==17078== by 0x44886F: virTestMain (testutils.c:969) ==17078== by 0x445D9B: main (qemuxml2argvtest.c:2036) Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
87df945240
commit
6b6e2cf92b
@ -547,6 +547,15 @@ qemuDomainWriteMasterKeyFile(virQEMUDriverPtr driver,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
qemuDomainMasterKeyFree(qemuDomainObjPrivatePtr priv)
|
||||
{
|
||||
if (!priv->masterKey)
|
||||
return;
|
||||
|
||||
VIR_DISPOSE_N(priv->masterKey, priv->masterKeyLen);
|
||||
}
|
||||
|
||||
/* qemuDomainMasterKeyReadFile:
|
||||
* @priv: pointer to domain private object
|
||||
*
|
||||
@ -645,9 +654,7 @@ qemuDomainMasterKeyRemove(qemuDomainObjPrivatePtr priv)
|
||||
return;
|
||||
|
||||
/* Clear the contents */
|
||||
memset(priv->masterKey, 0, priv->masterKeyLen);
|
||||
VIR_FREE(priv->masterKey);
|
||||
priv->masterKeyLen = 0;
|
||||
qemuDomainMasterKeyFree(priv);
|
||||
|
||||
/* Delete the master key file */
|
||||
path = qemuDomainGetMasterKeyFilePath(priv->libDir);
|
||||
@ -1317,6 +1324,7 @@ qemuDomainObjPrivateFree(void *data)
|
||||
|
||||
VIR_FREE(priv->libDir);
|
||||
VIR_FREE(priv->channelTargetDir);
|
||||
qemuDomainMasterKeyFree(priv);
|
||||
|
||||
VIR_FREE(priv);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user