From ce5ec2f1da21e605a9e4ab53ab8b08323c554298 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 7 Mar 2014 11:29:19 +0100 Subject: [PATCH] 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. --- src/storage/storage_backend_gluster.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c index 9a6180e2ca..5e0acc0651 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -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; -- 2.39.5