mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
qemu: caps: Rework memory allocation in virQEMUCapsFillDomainFeatureSEVCaps
Use g_new0 instead of VIR_ALLOC to avoid error cases. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
94af82b936
commit
e60174fb3a
@ -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;
|
||||
domCaps->sev = g_new0(virSEVCapability, 1);
|
||||
|
||||
sev->pdh = g_strdup(cap->pdh);
|
||||
|
||||
sev->cert_chain = g_strdup(cap->cert_chain);
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user