[PATCH] qemu: Resolve Coverity UNINIT

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

 



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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]