On 2/14/19 8:31 AM, Michal Privoznik wrote:
My change in 112f3a8d0f32 was too drastic. The @charAlias
variable is initialized only if @monitor == true. However, it is
used even outside of that condition, at which point it's just
uninitialized pointer.
Reported-by: John Ferlan <jferlan(a)redhat.com>
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_hotplug.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
Reviewed-by: John Ferlan <jferlan(a)redhat.com>
John
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index a5c352f44b..78c9a77f2d 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4754,13 +4754,12 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
VIR_DEBUG("Removing character device %s from domain %p %s",
chr->info.alias, vm, vm->def->name);
+ if (!(charAlias = qemuAliasChardevFromDevAlias(chr->info.alias)))
+ goto cleanup;
+
if (monitor) {
- if (!(charAlias = qemuAliasChardevFromDevAlias(chr->info.alias)))
- goto cleanup;
-
qemuDomainObjEnterMonitor(driver, vm);
rc = qemuMonitorDetachCharDev(priv->mon, charAlias);
-
Unrelated, but IDC.
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup;
}