[PATCH] cgroup: cleanup eventParams when virTypedParamsAddULLong failed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Function virTypedParamsAddULLong use realloc to gain memory,
and doesn't free it when failed. so we need free eventParams to
prevent a memory leak.

Signed-off-by: Xu Yandong <xuyandong2@xxxxxxxxxx>
---
 src/qemu/qemu_cgroup.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index ecd96efb0a..bc498e4b10 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -869,8 +869,11 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)
             if (virTypedParamsAddULLong(&eventParams, &eventNparams,
                                         &eventMaxparams,
                                         VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES,
-                                        val) < 0)
+                                        val) < 0) {
+                if (eventParams)
+                    virTypedParamsFree(eventParams, eventNparams);
                 return -1;
+            }
 
             event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams);
         }
-- 
2.18.1

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux