You need to sign in or sign up before continuing.
提交 ca1ac664 编写于 作者: M Michal Privoznik

qemuDomainAttachNetDevice: Avoid @originalError leak

Coverity identified that this variable might be leaked. And it's
right. If an error occurred and we have to roll back the control
jumps to try_remove label where we save the current error (see
0e82fa4c for more info). However, inside the code a jump onto
other label is possible thus leaking the error object.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 e555ed6f
...@@ -1326,8 +1326,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, ...@@ -1326,8 +1326,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
if (vlan < 0) { if (vlan < 0) {
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) { if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
char *netdev_name; char *netdev_name;
if (virAsprintf(&netdev_name, "host%s", net->info.alias) < 0) if (virAsprintf(&netdev_name, "host%s", net->info.alias) >= 0) {
goto cleanup;
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
if (charDevPlugged && if (charDevPlugged &&
qemuMonitorDetachCharDev(priv->mon, charDevAlias) < 0) qemuMonitorDetachCharDev(priv->mon, charDevAlias) < 0)
...@@ -1338,13 +1337,13 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, ...@@ -1338,13 +1337,13 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
netdev_name); netdev_name);
ignore_value(qemuDomainObjExitMonitor(driver, vm)); ignore_value(qemuDomainObjExitMonitor(driver, vm));
VIR_FREE(netdev_name); VIR_FREE(netdev_name);
}
} else { } else {
VIR_WARN("Unable to remove network backend"); VIR_WARN("Unable to remove network backend");
} }
} else { } else {
char *hostnet_name; char *hostnet_name;
if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0) if (virAsprintf(&hostnet_name, "host%s", net->info.alias) >= 0) {
goto cleanup;
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
if (hostPlugged && if (hostPlugged &&
qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0)
...@@ -1353,6 +1352,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, ...@@ -1353,6 +1352,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
ignore_value(qemuDomainObjExitMonitor(driver, vm)); ignore_value(qemuDomainObjExitMonitor(driver, vm));
VIR_FREE(hostnet_name); VIR_FREE(hostnet_name);
} }
}
virSetError(originalError); virSetError(originalError);
virFreeError(originalError); virFreeError(originalError);
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册