]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: gluster: Fix crash when initialization of storage backend fails
authorPeter Krempa <pkrempa@redhat.com>
Fri, 7 Mar 2014 10:29:19 +0000 (11:29 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 31 Mar 2014 11:47:50 +0000 (13:47 +0200)
The libgfapi function glfs_fini doesn't tolerate NULL pointers. Add a
check on the error paths as it's possible to crash libvirtd if the
gluster volume can't be initialized.

src/storage/storage_backend_gluster.c

index 9a6180e2ca48014c2037b2e2f3f67742fc8ce6c3..5e0acc0651b5a0380d8d8f5977eb0cebec70d9d9 100644 (file)
@@ -498,7 +498,8 @@ virStorageFileBackendGlusterDeinit(virStorageFilePtr file)
               file, file->hosts[0].name, file->path);
     virStorageFileBackendGlusterPrivPtr priv = file->priv;
 
-    glfs_fini(priv->vol);
+    if (priv->vol)
+        glfs_fini(priv->vol);
     VIR_FREE(priv->volname);
 
     VIR_FREE(priv);
@@ -571,7 +572,8 @@ virStorageFileBackendGlusterInit(virStorageFilePtr file)
 
  error:
     VIR_FREE(priv->volname);
-    glfs_fini(priv->vol);
+    if (priv->vol)
+        glfs_fini(priv->vol);
     VIR_FREE(priv);
 
     return -1;