[libvirt] [PATCH] qemu: Resolve Coverity UNINIT

John Ferlan jferlan at redhat.com
Sat Aug 15 13:18:14 UTC 2015


Coverity complained that 'vm' wasn't initialized before jumping to
cleanup: and calling virDomainObjEndAPI if the VIR_STRDUP fails.
Rather than initialize vm = NULL, I moved the VIR_STRDUP closer to
usage and used endjob for goto.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/qemu/qemu_driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3683591..a54a3dd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19902,9 +19902,6 @@ static int qemuDomainRename(virDomainPtr dom,
 
     virCheckFlags(0, ret);
 
-    if (VIR_STRDUP(new_dom_name, new_name) < 0)
-        goto cleanup;
-
     if (!(vm = qemuDomObjFromDomain(dom)))
         goto cleanup;
 
@@ -19940,6 +19937,9 @@ static int qemuDomainRename(virDomainPtr dom,
         goto endjob;
     }
 
+    if (VIR_STRDUP(new_dom_name, new_name) < 0)
+        goto endjob;
+
     if (virAsprintf(&rename_log_msg, ": domain %s has been renamed to %s\n",
                     vm->def->name, new_name) < 0) {
         goto endjob;
-- 
2.1.0




More information about the libvir-list mailing list