mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 13:17:58 +03:00
cpu_x86: Resolve Coverity RESOURCE_LEAK
Coverity determined that the copied 'oldguest' would be leaked for both error and success paths.
This commit is contained in:
parent
f9c827e383
commit
be7b82a283
@ -2024,8 +2024,9 @@ static int
|
|||||||
x86UpdateHostModel(virCPUDefPtr guest,
|
x86UpdateHostModel(virCPUDefPtr guest,
|
||||||
const virCPUDef *host)
|
const virCPUDef *host)
|
||||||
{
|
{
|
||||||
virCPUDefPtr oldguest;
|
virCPUDefPtr oldguest = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
guest->match = VIR_CPU_MATCH_EXACT;
|
guest->match = VIR_CPU_MATCH_EXACT;
|
||||||
|
|
||||||
@ -2037,20 +2038,24 @@ x86UpdateHostModel(virCPUDefPtr guest,
|
|||||||
|
|
||||||
/* update the host model according to the desired configuration */
|
/* update the host model according to the desired configuration */
|
||||||
if (!(oldguest = virCPUDefCopy(guest)))
|
if (!(oldguest = virCPUDefCopy(guest)))
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
virCPUDefFreeModel(guest);
|
virCPUDefFreeModel(guest);
|
||||||
if (virCPUDefCopyModel(guest, host, true) < 0)
|
if (virCPUDefCopyModel(guest, host, true) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < oldguest->nfeatures; i++) {
|
for (i = 0; i < oldguest->nfeatures; i++) {
|
||||||
if (virCPUDefUpdateFeature(guest,
|
if (virCPUDefUpdateFeature(guest,
|
||||||
oldguest->features[i].name,
|
oldguest->features[i].name,
|
||||||
oldguest->features[i].policy) < 0)
|
oldguest->features[i].policy) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virCPUDefFree(oldguest);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user