[libvirt] [PATCH] conf: fix class_id bitmap leak in virNetworkObj

Commit '07d1b6b' added class_id bitmap to virNetworkObj but never freed it. --- src/conf/network_conf.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 48639a9..9c35ea8 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -235,6 +235,7 @@ void virNetworkObjFree(virNetworkObjPtr net) virNetworkDefFree(net->def); virNetworkDefFree(net->newDef); + virBitmapFree(net->class_id); virMutexDestroy(&net->lock); -- 1.7.8.6

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

On 01/15/13 17:31, Laine Stump wrote:
On 01/15/2013 09:48 AM, Ján Tomko wrote:
Fix the leak of vcpupin on failure to allocate cpumask and the leak of cpumask if we fail to expand vcpupin_list.
ACK.
Thanks, both pushed now.

On 01/15/2013 09:48 AM, Ján Tomko wrote:
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);
s/vpcupin/vcpupin
+ return -1; }
int

On 01/15/2013 09:48 AM, Ján Tomko wrote:
Commit '07d1b6b' added class_id bitmap to virNetworkObj but never freed it. --- src/conf/network_conf.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 48639a9..9c35ea8 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -235,6 +235,7 @@ void virNetworkObjFree(virNetworkObjPtr net)
virNetworkDefFree(net->def); virNetworkDefFree(net->newDef); + virBitmapFree(net->class_id);
virMutexDestroy(&net->lock);
ACK.
participants (3)
-
John Ferlan
-
Ján Tomko
-
Laine Stump