[PATCH] qemu_hotplug: Initialize @charAlias in qemuDomainRemoveChrDevice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_hotplug.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

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);
-
         if (qemuDomainObjExitMonitor(driver, vm) < 0)
             goto cleanup;
     }
-- 
2.19.2


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux