Fix the leak of vcpupin on failure to allocate cpumask and the leak of
cpumask if we fail to expand vcpupin_list.
---
src/conf/domain_conf.c | 25 ++++++++++++-------------
1 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6feded4..95ecd9d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11908,26 +11908,25 @@ int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr **vcpupin_list,
/* No existing vcpupin matches vcpu, adding a new one */
- if (VIR_ALLOC(vcpupin) < 0) {
- virReportOOMError();
- return -1;
- }
+ if (VIR_ALLOC(vcpupin) < 0)
+ goto no_memory;
+
vcpupin->vcpuid = vcpu;
vcpupin->cpumask = virBitmapNewData(cpumap, maplen);
- if (!vcpupin->cpumask) {
- virReportOOMError();
- return -1;
- }
+ if (!vcpupin->cpumask)
+ goto no_memory;
- if (VIR_REALLOC_N(*vcpupin_list, *nvcpupin + 1) < 0) {
- virReportOOMError();
- VIR_FREE(vcpupin);
- return -1;
- }
+ if (VIR_REALLOC_N(*vcpupin_list, *nvcpupin + 1) < 0)
+ goto no_memory;
(*vcpupin_list)[(*nvcpupin)++] = vcpupin;
return 0;
+
+no_memory:
+ virReportOOMError();
+ virDomainVcpuPinDefFree(vpcupin);
+ return -1;
}
int
--
1.7.8.6