summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/super.c4
-rw-r--r--fs/namespace.c2
-rw-r--r--fs/nfs/super.c23
3 files changed, 11 insertions, 18 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 969a7747e88..cfbedd7755b 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -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
diff --git a/fs/namespace.c b/fs/namespace.c
index e5e1c7d1839..aea4b768984 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -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;
}
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 480b3b6bf71..46d69f38fd5 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -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,