[PATCH 1/3] lxc_process: Resolve Coverity NULL_RETURNS error

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

 



In virLXCProcessReboot, if the 'conn' value is NULL, the eventual
call to virLXCNetworkLookupByName() via virLXCProcessStart() and
virLXCProcessSetupInterfaces() will cause a core since it references
conn->networkDriver directly.
---
 src/lxc/lxc_process.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index b06d748..4410db4 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -181,7 +181,6 @@ virLXCProcessReboot(virLXCDriverPtr driver,
         autodestroy = true;
     } else {
         conn = virConnectOpen("lxc:///");
-        /* Ignoring NULL conn which is mostly harmless here */
     }
 
     /* In a reboot scenario, we need to make sure we continue
@@ -192,7 +191,8 @@ virLXCProcessReboot(virLXCDriverPtr driver,
     vm->newDef = NULL;
     virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
     vm->newDef = savedDef;
-    if (virLXCProcessStart(conn, driver, vm, autodestroy, reason) < 0) {
+    if (!conn ||
+        virLXCProcessStart(conn, driver, vm, autodestroy, reason) < 0) {
         VIR_WARN("Unable to handle reboot of vm %s",
                  vm->def->name);
         goto cleanup;
-- 
1.8.1.4

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