switch create_mnt_ns() to saner calling conventions, fix double mntput() in nfs
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 16 Nov 2011 21:12:14 +0000 (16:12 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 16 Nov 2011 21:12:14 +0000 (16:12 -0500)
Life is much saner if create_mnt_ns(mnt) drops mnt in case of error...
Switch it to such calling conventions, switch callers, fix double mntput() in
fs/nfs/super.c one.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/btrfs/super.c
fs/namespace.c
fs/nfs/super.c

index 969a7747e88981ece48796452e3cfe46b607f0bd..cfbedd7755b0478288e7e2ba2e552c32ec17a550 100644 (file)
@@ -843,10 +843,8 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags,
                return ERR_CAST(mnt);
 
        ns_private = create_mnt_ns(mnt);
-       if (IS_ERR(ns_private)) {
-               mntput(mnt);
+       if (IS_ERR(ns_private))
                return ERR_CAST(ns_private);
-       }
 
        /*
         * This will trigger the automount of the subvol so we can just
index e5e1c7d1839b791f0c52428a9ffe058bd7ded092..aea4b7689840763e81b5cd0d02c7c71e457d662a 100644 (file)
@@ -2483,6 +2483,8 @@ struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt)
                __mnt_make_longterm(mnt);
                new_ns->root = mnt;
                list_add(&new_ns->list, &new_ns->root->mnt_list);
+       } else {
+               mntput(mnt);
        }
        return new_ns;
 }
index 480b3b6bf71ef82f122a433cbf3ec62d789c033a..46d69f38fd55a70a9009297822b339e804a30f8e 100644 (file)
@@ -2794,22 +2794,21 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
        int ret;
 
        ns_private = create_mnt_ns(root_mnt);
-       ret = PTR_ERR(ns_private);
        if (IS_ERR(ns_private))
-               goto out_mntput;
+               return ERR_CAST(ns_private);
 
        ret = nfs_referral_loop_protect();
-       if (ret != 0)
-               goto out_put_mnt_ns;
-
-       ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt,
-                       export_path, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &path);
+       if (ret == 0) {
+               ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt,
+                               export_path, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT,
+                               &path);
+               nfs_referral_loop_unprotect();
+       }
 
-       nfs_referral_loop_unprotect();
        put_mnt_ns(ns_private);
 
        if (ret != 0)
-               goto out_err;
+               return ERR_PTR(ret);
 
        s = path.mnt->mnt_sb;
        atomic_inc(&s->s_active);
@@ -2818,12 +2817,6 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
        path_put(&path);
        down_write(&s->s_umount);
        return dentry;
-out_put_mnt_ns:
-       put_mnt_ns(ns_private);
-out_mntput:
-       mntput(root_mnt);
-out_err:
-       return ERR_PTR(ret);
 }
 
 static struct dentry *nfs4_try_mount(int flags, const char *dev_name,