storage: gluster: Fix crash when initialization of storage backend fails

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.
This commit is contained in:
Peter Krempa 2014-03-07 11:29:19 +01:00
parent 8617e8c8bb
commit ce5ec2f1da

View 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;