提交 6f8a4f6d 编写于 作者: J John Ferlan

qemu_agent: Resolve Coverity RESOURCE_LEAK

Coverity found that on error paths, the 'arg' value wasn't be cleaned
up. Followed the example in qemuAgentSetVCPUs() where upon successful call
to qemuAgentCommand() the 'cpus' is set to NULL; otherwise, when cleanup
occurs the free the memory for 'arg'
上级 461fb555
...@@ -1328,7 +1328,7 @@ int qemuAgentFSFreeze(qemuAgentPtr mon, const char **mountpoints, ...@@ -1328,7 +1328,7 @@ int qemuAgentFSFreeze(qemuAgentPtr mon, const char **mountpoints,
unsigned int nmountpoints) unsigned int nmountpoints)
{ {
int ret = -1; int ret = -1;
virJSONValuePtr cmd, arg; virJSONValuePtr cmd, arg = NULL;
virJSONValuePtr reply = NULL; virJSONValuePtr reply = NULL;
if (mountpoints && nmountpoints) { if (mountpoints && nmountpoints) {
...@@ -1343,7 +1343,8 @@ int qemuAgentFSFreeze(qemuAgentPtr mon, const char **mountpoints, ...@@ -1343,7 +1343,8 @@ int qemuAgentFSFreeze(qemuAgentPtr mon, const char **mountpoints,
} }
if (!cmd) if (!cmd)
return -1; goto cleanup;
arg = NULL;
if (qemuAgentCommand(mon, cmd, &reply, true, if (qemuAgentCommand(mon, cmd, &reply, true,
VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
...@@ -1355,6 +1356,7 @@ int qemuAgentFSFreeze(qemuAgentPtr mon, const char **mountpoints, ...@@ -1355,6 +1356,7 @@ int qemuAgentFSFreeze(qemuAgentPtr mon, const char **mountpoints,
} }
cleanup: cleanup:
virJSONValueFree(arg);
virJSONValueFree(cmd); virJSONValueFree(cmd);
virJSONValueFree(reply); virJSONValueFree(reply);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册