|
|
c8c376 |
From a52fbab4f76d05c3764dad87333c0cefd0004e8f Mon Sep 17 00:00:00 2001
|
|
|
c8c376 |
Message-Id: <a52fbab4f76d05c3764dad87333c0cefd0004e8f@dist-git>
|
|
|
c8c376 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
c8c376 |
Date: Thu, 22 Dec 2016 14:23:05 +0100
|
|
|
c8c376 |
Subject: [PATCH] qemuDomainAttachNetDevice: Avoid @originalError leak
|
|
|
c8c376 |
|
|
|
c8c376 |
RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1404186
|
|
|
c8c376 |
|
|
|
c8c376 |
Coverity identified that this variable might be leaked. And it's
|
|
|
c8c376 |
right. If an error occurred and we have to roll back the control
|
|
|
c8c376 |
jumps to try_remove label where we save the current error (see
|
|
|
c8c376 |
0e82fa4c34 for more info). However, inside the code a jump onto
|
|
|
c8c376 |
other label is possible thus leaking the error object.
|
|
|
c8c376 |
|
|
|
c8c376 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
c8c376 |
(cherry picked from commit ca1ac6643e8b466487597f981fad15abc5f336b4)
|
|
|
c8c376 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
c8c376 |
---
|
|
|
c8c376 |
src/qemu/qemu_hotplug.c | 42 +++++++++++++++++++++---------------------
|
|
|
c8c376 |
1 file changed, 21 insertions(+), 21 deletions(-)
|
|
|
c8c376 |
|
|
|
c8c376 |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
c8c376 |
index 62e275e94..58d25ca0e 100644
|
|
|
c8c376 |
--- a/src/qemu/qemu_hotplug.c
|
|
|
c8c376 |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
c8c376 |
@@ -1279,32 +1279,32 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|
|
c8c376 |
if (vlan < 0) {
|
|
|
c8c376 |
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV)) {
|
|
|
c8c376 |
char *netdev_name;
|
|
|
c8c376 |
- if (virAsprintf(&netdev_name, "host%s", net->info.alias) < 0)
|
|
|
c8c376 |
- goto cleanup;
|
|
|
c8c376 |
- qemuDomainObjEnterMonitor(driver, vm);
|
|
|
c8c376 |
- if (charDevPlugged &&
|
|
|
c8c376 |
- qemuMonitorDetachCharDev(priv->mon, charDevAlias) < 0)
|
|
|
c8c376 |
- VIR_WARN("Failed to remove associated chardev %s", charDevAlias);
|
|
|
c8c376 |
- if (netdevPlugged &&
|
|
|
c8c376 |
- qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0)
|
|
|
c8c376 |
- VIR_WARN("Failed to remove network backend for netdev %s",
|
|
|
c8c376 |
- netdev_name);
|
|
|
c8c376 |
- ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
|
|
c8c376 |
- VIR_FREE(netdev_name);
|
|
|
c8c376 |
+ if (virAsprintf(&netdev_name, "host%s", net->info.alias) >= 0) {
|
|
|
c8c376 |
+ qemuDomainObjEnterMonitor(driver, vm);
|
|
|
c8c376 |
+ if (charDevPlugged &&
|
|
|
c8c376 |
+ qemuMonitorDetachCharDev(priv->mon, charDevAlias) < 0)
|
|
|
c8c376 |
+ VIR_WARN("Failed to remove associated chardev %s", charDevAlias);
|
|
|
c8c376 |
+ if (netdevPlugged &&
|
|
|
c8c376 |
+ qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0)
|
|
|
c8c376 |
+ VIR_WARN("Failed to remove network backend for netdev %s",
|
|
|
c8c376 |
+ netdev_name);
|
|
|
c8c376 |
+ ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
|
|
c8c376 |
+ VIR_FREE(netdev_name);
|
|
|
c8c376 |
+ }
|
|
|
c8c376 |
} else {
|
|
|
c8c376 |
VIR_WARN("Unable to remove network backend");
|
|
|
c8c376 |
}
|
|
|
c8c376 |
} else {
|
|
|
c8c376 |
char *hostnet_name;
|
|
|
c8c376 |
- if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0)
|
|
|
c8c376 |
- goto cleanup;
|
|
|
c8c376 |
- qemuDomainObjEnterMonitor(driver, vm);
|
|
|
c8c376 |
- if (hostPlugged &&
|
|
|
c8c376 |
- qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0)
|
|
|
c8c376 |
- VIR_WARN("Failed to remove network backend for vlan %d, net %s",
|
|
|
c8c376 |
- vlan, hostnet_name);
|
|
|
c8c376 |
- ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
|
|
c8c376 |
- VIR_FREE(hostnet_name);
|
|
|
c8c376 |
+ if (virAsprintf(&hostnet_name, "host%s", net->info.alias) >= 0) {
|
|
|
c8c376 |
+ qemuDomainObjEnterMonitor(driver, vm);
|
|
|
c8c376 |
+ if (hostPlugged &&
|
|
|
c8c376 |
+ qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0)
|
|
|
c8c376 |
+ VIR_WARN("Failed to remove network backend for vlan %d, net %s",
|
|
|
c8c376 |
+ vlan, hostnet_name);
|
|
|
c8c376 |
+ ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
|
|
c8c376 |
+ VIR_FREE(hostnet_name);
|
|
|
c8c376 |
+ }
|
|
|
c8c376 |
}
|
|
|
c8c376 |
virSetError(originalError);
|
|
|
c8c376 |
virFreeError(originalError);
|
|
|
c8c376 |
--
|
|
|
c8c376 |
2.11.0
|
|
|
c8c376 |
|