提交 e60174fb 编写于 作者: P Peter Krempa

qemu: caps: Rework memory allocation in virQEMUCapsFillDomainFeatureSEVCaps

Use g_new0 instead of VIR_ALLOC to avoid error cases.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 94af82b9
......@@ -5572,21 +5572,16 @@ virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr qemuCaps,
virDomainCapsPtr domCaps)
{
virSEVCapability *cap = qemuCaps->sevCapabilities;
g_autoptr(virSEVCapability) sev = NULL;
if (!cap)
return 0;
if (VIR_ALLOC(sev) < 0)
return -1;
sev->pdh = g_strdup(cap->pdh);
sev->cert_chain = g_strdup(cap->cert_chain);
domCaps->sev = g_new0(virSEVCapability, 1);
sev->cbitpos = cap->cbitpos;
sev->reduced_phys_bits = cap->reduced_phys_bits;
domCaps->sev = g_steal_pointer(&sev);
domCaps->sev->pdh = g_strdup(cap->pdh);
domCaps->sev->cert_chain = g_strdup(cap->cert_chain);
domCaps->sev->cbitpos = cap->cbitpos;
domCaps->sev->reduced_phys_bits = cap->reduced_phys_bits;
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册