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

John Ferlan jferlan at redhat.com
Thu May 16 14:01:51 UTC 2013


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




More information about the libvir-list mailing list