1 Star 0 Fork 70

mds.lanruo/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
libvirt-qemu-fix-potential-memory-leak.patch 2.29 KB
一键复制 编辑 原始数据 按行查看 历史
From 4f4ebf64009e402db79bf53db1226966bf5c0a99 Mon Sep 17 00:00:00 2001
From: Feng Ni <[email protected]>
Date: Wed, 15 Apr 2020 11:11:16 +0800
Subject: qemu: fix potential memory leak
function virTypedParamsAddString may return -1 but alloc params,
so invoker should free it.
Signed-off-by: Feng Ni <[email protected]>
Signed-off-by: Xu Yandong <[email protected]>
---
src/qemu/qemu_driver.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ff97f10..8bc5368 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5175,6 +5175,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
goto cleanup;
event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams);
+ eventParams = NULL;
+ eventNparams = 0;
ret = 0;
@@ -5182,6 +5184,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
virBitmapFree(tmpmap);
virCgroupFree(&cgroup_vcpu);
virObjectEventStateQueue(driver->domainEventState, event);
+ if (eventParams)
+ virTypedParamsFree(eventParams, eventNparams);
return ret;
}
@@ -5388,6 +5392,8 @@ qemuDomainPinEmulator(virDomainPtr dom,
goto endjob;
event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
+ eventParams = NULL;
+ eventNparams = 0;
}
if (persistentDef) {
@@ -5409,6 +5415,8 @@ qemuDomainPinEmulator(virDomainPtr dom,
cleanup:
if (cgroup_emulator)
virCgroupFree(&cgroup_emulator);
+ if (eventParams)
+ virTypedParamsFree(eventParams, eventNparams);
virObjectEventStateQueue(driver->domainEventState, event);
virBitmapFree(pcpumap);
virDomainObjEndAPI(&vm);
@@ -5871,6 +5879,8 @@ qemuDomainPinIOThread(virDomainPtr dom,
goto endjob;
event = virDomainEventTunableNewFromDom(dom, eventParams, eventNparams);
+ eventParams = NULL;
+ eventNparams = 0;
}
if (persistentDef) {
@@ -5902,6 +5912,8 @@ qemuDomainPinIOThread(virDomainPtr dom,
cleanup:
if (cgroup_iothread)
virCgroupFree(&cgroup_iothread);
+ if (eventParams)
+ virTypedParamsFree(eventParams, eventNparams);
virObjectEventStateQueue(driver->domainEventState, event);
virBitmapFree(pcpumap);
virDomainObjEndAPI(&vm);
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mdslanruo/libvirt.git
[email protected]:mdslanruo/libvirt.git
mdslanruo
libvirt
libvirt
master

搜索帮助