vfs_ceph: cleanup mount handle on failure
authorDavid Disseldorp <ddiss@samba.org>
Wed, 8 Feb 2017 16:11:30 +0000 (17:11 +0100)
committerDavid Disseldorp <ddiss@samba.org>
Wed, 15 Feb 2017 16:04:14 +0000 (17:04 +0100)
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source3/modules/vfs_ceph.c

index 75233ef677f1c1177a07f3c1fc7246e31f64bf0c..1cd364269b5e4df3b96f3220bcc7a1036dc332b0 100644 (file)
@@ -111,19 +111,21 @@ static int cephwrap_connect(struct vfs_handle_struct *handle,  const char *servi
                ret = ceph_conf_read_file(cmount, NULL);
        }
 
-       if (ret)
-               goto err_out;
+       if (ret) {
+               goto err_cm_release;
+       }
 
        DBG_DEBUG( "[CEPH] calling: ceph_conf_get\n" );
        ret = ceph_conf_get(cmount, "log file", buf, sizeof(buf));
-       if (ret < 0)
-               goto err_out;
+       if (ret < 0) {
+               goto err_cm_release;
+       }
 
        DBG_DEBUG("[CEPH] calling: ceph_mount\n");
        ret = ceph_mount(cmount, NULL);
-       if (ret < 0)
-               goto err_out;
-
+       if (ret < 0) {
+               goto err_cm_release;
+       }
 
        /*
         * encode mount context/state into our vfs/connection holding structure
@@ -134,6 +136,9 @@ static int cephwrap_connect(struct vfs_handle_struct *handle,  const char *servi
 
        return 0;
 
+err_cm_release:
+       ceph_release(cmount);
+       cmount = NULL;
 err_out:
        /*
         * Handle the error correctly. Ceph returns -errno.