From 53d03ba837fb32ae09f6b1cecd11f03ad97ef8f2 Mon Sep 17 00:00:00 2001 From: Wen Congyang Date: Tue, 28 Jun 2011 11:41:15 +0800 Subject: [PATCH] Fix memory leak in virDomainVcpuPinDel() virDomainVcpuPinDefFree() does not free def->cputune.vcpupin if nvcpupin is 0, and does not set def->cputune.vcpupin to NULL. If we set nvcpupin to 0 but do not free vcpupin, vcpupin will not be freed when vm->def is freed. Use VIR_FREE() instead of virDomainVcpuPinDefFree() to free the memory and set def->cputune.vcpupint to NULL. --- src/conf/domain_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 60e0318a41..f9bf51e3c7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8263,7 +8263,7 @@ virDomainVcpuPinDel(virDomainDefPtr def, int vcpu) return 0; if (--def->cputune.nvcpupin == 0) { - virDomainVcpuPinDefFree(def->cputune.vcpupin, 0); + VIR_FREE(def->cputune.vcpupin); } else { if (VIR_REALLOC_N(def->cputune.vcpupin, def->cputune.nvcpupin) < 0) { virReportOOMError(); -- GitLab