]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
uml: umlConnectOpen: Check the driver pointer before accessing it
authorJulio Faracco <jcfaracco@gmail.com>
Fri, 28 Sep 2018 04:13:28 +0000 (01:13 -0300)
committerErik Skultety <eskultet@redhat.com>
Mon, 1 Oct 2018 07:13:44 +0000 (09:13 +0200)
The pointer related to uml_driver needs to be checked before its usage
inside the function. Some attributes of the driver are being accessed
while the pointer is NULL considering the current logic.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/uml/uml_driver.c

index fcd468243e596da8e17e22379cd58d5bb2301e3f..d1c71d8521797385847f04d0cd16641dbc971940 100644 (file)
@@ -1193,6 +1193,13 @@ static virDrvOpenStatus umlConnectOpen(virConnectPtr conn,
 {
     virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
 
+    /* URI was good, but driver isn't active */
+    if (uml_driver == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("uml state driver is not active"));
+        return VIR_DRV_OPEN_ERROR;
+    }
+
     /* Check path and tell them correct path if they made a mistake */
     if (uml_driver->privileged) {
         if (STRNEQ(conn->uri->path, "/system") &&
@@ -1211,13 +1218,6 @@ static virDrvOpenStatus umlConnectOpen(virConnectPtr conn,
         }
     }
 
-    /* URI was good, but driver isn't active */
-    if (uml_driver == NULL) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("uml state driver is not active"));
-        return VIR_DRV_OPEN_ERROR;
-    }
-
     if (virConnectOpenEnsureACL(conn) < 0)
         return VIR_DRV_OPEN_ERROR;