[libvirt] [PATCH] virresctrl: fix MBA memory leak

Pavel Hrdina posted 1 patch 9 weeks ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/b58961a5f34f5035c3db1ade2acafeaaa923789d.1554995831.git.phrdina@redhat.com
src/util/virresctrl.c | 1 +
1 file changed, 1 insertion(+)

[libvirt] [PATCH] virresctrl: fix MBA memory leak

Posted by Pavel Hrdina 9 weeks ago
The 'bandwidths' variable is allocated using VIR_RESIZE_N so it has to
be freed as well.

==118315== 8 bytes in 1 blocks are definitely lost in loss record 299 of 2,401
==118315==    at 0x4C29DAD: malloc (vg_replace_malloc.c:308)
==118315==    by 0x4C2C100: realloc (vg_replace_malloc.c:836)
==118315==    by 0x52C3FAF: virReallocN (viralloc.c:245)
==118315==    by 0x52C4079: virExpandN (viralloc.c:294)
==118315==    by 0x532BBA8: virResctrlAllocParseProcessMemoryBandwidth (virresctrl.c:1156)
==118315==    by 0x532BBA8: virResctrlAllocParseMemoryBandwidthLine (virresctrl.c:1211)
==118315==    by 0x532BBA8: virResctrlAllocParse (virresctrl.c:1414)
==118315==    by 0x532BBA8: virResctrlAllocGetGroup (virresctrl.c:1446)
==118315==    by 0x532C11D: virResctrlAllocGetDefault (virresctrl.c:1464)
==118315==    by 0x532D15E: virResctrlAllocAssign (virresctrl.c:1923)
==118315==    by 0x532D15E: virResctrlAllocCreate (virresctrl.c:2042)
==118315==    by 0x31E1ABEE: qemuProcessResctrlCreate (qemu_process.c:2596)
==118315==    by 0x31E1ABEE: qemuProcessLaunch (qemu_process.c:6444)
==118315==    by 0x31E1E341: qemuProcessStart (qemu_process.c:6721)
==118315==    by 0x31E81315: qemuDomainObjStart.constprop.50 (qemu_driver.c:7288)
==118315==    by 0x31E81A65: qemuDomainCreateWithFlags (qemu_driver.c:7341)
==118315==    by 0x54DDB4B: virDomainCreate (libvirt-domain.c:6534)

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/util/virresctrl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 9e477fc064..87feb4bdcf 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -407,6 +407,7 @@ virResctrlAllocDispose(void *obj)
         virResctrlAllocMemBWPtr mem_bw = alloc->mem_bw;
         for (i = 0; i < mem_bw->nbandwidths; i++)
             VIR_FREE(mem_bw->bandwidths[i]);
+        VIR_FREE(alloc->mem_bw->bandwidths);
         VIR_FREE(alloc->mem_bw);
     }
 
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] virresctrl: fix MBA memory leak

Posted by Peter Krempa 9 weeks ago
On Thu, Apr 11, 2019 at 17:17:22 +0200, Pavel Hrdina wrote:
> The 'bandwidths' variable is allocated using VIR_RESIZE_N so it has to
> be freed as well.
> 
> ==118315== 8 bytes in 1 blocks are definitely lost in loss record 299 of 2,401
> ==118315==    at 0x4C29DAD: malloc (vg_replace_malloc.c:308)
> ==118315==    by 0x4C2C100: realloc (vg_replace_malloc.c:836)
> ==118315==    by 0x52C3FAF: virReallocN (viralloc.c:245)
> ==118315==    by 0x52C4079: virExpandN (viralloc.c:294)
> ==118315==    by 0x532BBA8: virResctrlAllocParseProcessMemoryBandwidth (virresctrl.c:1156)
> ==118315==    by 0x532BBA8: virResctrlAllocParseMemoryBandwidthLine (virresctrl.c:1211)
> ==118315==    by 0x532BBA8: virResctrlAllocParse (virresctrl.c:1414)
> ==118315==    by 0x532BBA8: virResctrlAllocGetGroup (virresctrl.c:1446)
> ==118315==    by 0x532C11D: virResctrlAllocGetDefault (virresctrl.c:1464)
> ==118315==    by 0x532D15E: virResctrlAllocAssign (virresctrl.c:1923)
> ==118315==    by 0x532D15E: virResctrlAllocCreate (virresctrl.c:2042)
> ==118315==    by 0x31E1ABEE: qemuProcessResctrlCreate (qemu_process.c:2596)
> ==118315==    by 0x31E1ABEE: qemuProcessLaunch (qemu_process.c:6444)
> ==118315==    by 0x31E1E341: qemuProcessStart (qemu_process.c:6721)
> ==118315==    by 0x31E81315: qemuDomainObjStart.constprop.50 (qemu_driver.c:7288)
> ==118315==    by 0x31E81A65: qemuDomainCreateWithFlags (qemu_driver.c:7341)
> ==118315==    by 0x54DDB4B: virDomainCreate (libvirt-domain.c:6534)
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  src/util/virresctrl.c | 1 +
>  1 file changed, 1 insertion(+)

ACK
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list