aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 3d08478d3130..23a1ad467976 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -576,6 +576,23 @@ int follow_up(struct vfsmount **mnt, struct dentry **dentry)
576/* no need for dcache_lock, as serialization is taken care in 576/* no need for dcache_lock, as serialization is taken care in
577 * namespace.c 577 * namespace.c
578 */ 578 */
579static int __follow_mount(struct path *path)
580{
581 int res = 0;
582 while (d_mountpoint(path->dentry)) {
583 struct vfsmount *mounted = lookup_mnt(path->mnt, path->dentry);
584 if (!mounted)
585 break;
586 dput(path->dentry);
587 if (res)
588 mntput(path->mnt);
589 path->mnt = mounted;
590 path->dentry = dget(mounted->mnt_root);
591 res = 1;
592 }
593 return res;
594}
595
579static int follow_mount(struct vfsmount **mnt, struct dentry **dentry) 596static int follow_mount(struct vfsmount **mnt, struct dentry **dentry)
580{ 597{
581 int res = 0; 598 int res = 0;
@@ -778,7 +795,9 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd)
778 if (err) 795 if (err)
779 break; 796 break;
780 /* Check mountpoints.. */ 797 /* Check mountpoints.. */
781 follow_mount(&next.mnt, &next.dentry); 798 __follow_mount(&next);
799 if (nd->mnt != next.mnt)
800 mntput(nd->mnt);
782 801
783 err = -ENOENT; 802 err = -ENOENT;
784 inode = next.dentry->d_inode; 803 inode = next.dentry->d_inode;
@@ -836,7 +855,9 @@ last_component:
836 err = do_lookup(nd, &this, &next); 855 err = do_lookup(nd, &this, &next);
837 if (err) 856 if (err)
838 break; 857 break;
839 follow_mount(&next.mnt, &next.dentry); 858 __follow_mount(&next);
859 if (nd->mnt != next.mnt)
860 mntput(nd->mnt);
840 inode = next.dentry->d_inode; 861 inode = next.dentry->d_inode;
841 if ((lookup_flags & LOOKUP_FOLLOW) 862 if ((lookup_flags & LOOKUP_FOLLOW)
842 && inode && inode->i_op && inode->i_op->follow_link) { 863 && inode && inode->i_op && inode->i_op->follow_link) {