render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
99cbc7
From 2aadab4741e8637196e729044893584bf4bde33f Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <2aadab4741e8637196e729044893584bf4bde33f@dist-git>
99cbc7
From: Michal Privoznik <mprivozn@redhat.com>
99cbc7
Date: Thu, 25 Apr 2019 09:24:47 +0200
99cbc7
Subject: [PATCH] qemu_hotplug: Initialize @charAlias in
99cbc7
 qemuDomainRemoveChrDevice
99cbc7
99cbc7
My change in 112f3a8d0f32 was too drastic. The @charAlias
99cbc7
variable is initialized only if @monitor == true. However, it is
99cbc7
used even outside of that condition, at which point it's just
99cbc7
uninitialized pointer.
99cbc7
99cbc7
Reported-by: John Ferlan <jferlan@redhat.com>
99cbc7
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
Reviewed-by: John Ferlan <jferlan@redhat.com>
99cbc7
(cherry picked from commit 4b23f18d2c9e13ac6f33fb45dbb79931082125bb)
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1658198
99cbc7
99cbc7
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Message-Id: <92831aceb87c1bc226a77904766f434d86f62675.1556177047.git.jdenemar@redhat.com>
99cbc7
Acked-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_hotplug.c | 7 +++----
99cbc7
 1 file changed, 3 insertions(+), 4 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
99cbc7
index 7ad8007a3a..ca8b0aaf62 100644
99cbc7
--- a/src/qemu/qemu_hotplug.c
99cbc7
+++ b/src/qemu/qemu_hotplug.c
99cbc7
@@ -4364,13 +4364,12 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
99cbc7
     VIR_DEBUG("Removing character device %s from domain %p %s",
99cbc7
               chr->info.alias, vm, vm->def->name);
99cbc7
 
99cbc7
-    if (monitor) {
99cbc7
-        if (!(charAlias = qemuAliasChardevFromDevAlias(chr->info.alias)))
99cbc7
-            goto cleanup;
99cbc7
+    if (!(charAlias = qemuAliasChardevFromDevAlias(chr->info.alias)))
99cbc7
+        goto cleanup;
99cbc7
 
99cbc7
+    if (monitor) {
99cbc7
         qemuDomainObjEnterMonitor(driver, vm);
99cbc7
         rc = qemuMonitorDetachCharDev(priv->mon, charAlias);
99cbc7
-
99cbc7
         if (qemuDomainObjExitMonitor(driver, vm) < 0)
99cbc7
             goto cleanup;
99cbc7
     }
99cbc7
-- 
99cbc7
2.21.0
99cbc7