diff options
-rw-r--r-- | fs/namei.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/namei.c b/fs/namei.c index abeec34e7553..12d75ed214f6 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -526,6 +526,7 @@ static inline int __do_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
526 | static inline int do_follow_link(struct path *path, struct nameidata *nd) | 526 | static inline int do_follow_link(struct path *path, struct nameidata *nd) |
527 | { | 527 | { |
528 | int err = -ELOOP; | 528 | int err = -ELOOP; |
529 | mntget(path->mnt); | ||
529 | if (current->link_count >= MAX_NESTED_LINKS) | 530 | if (current->link_count >= MAX_NESTED_LINKS) |
530 | goto loop; | 531 | goto loop; |
531 | if (current->total_link_count >= 40) | 532 | if (current->total_link_count >= 40) |
@@ -541,9 +542,13 @@ static inline int do_follow_link(struct path *path, struct nameidata *nd) | |||
541 | err = __do_follow_link(path->dentry, nd); | 542 | err = __do_follow_link(path->dentry, nd); |
542 | current->link_count--; | 543 | current->link_count--; |
543 | nd->depth--; | 544 | nd->depth--; |
545 | dput(path->dentry); | ||
546 | mntput(path->mnt); | ||
544 | return err; | 547 | return err; |
545 | loop: | 548 | loop: |
546 | path_release(nd); | 549 | path_release(nd); |
550 | dput(path->dentry); | ||
551 | mntput(path->mnt); | ||
547 | return err; | 552 | return err; |
548 | } | 553 | } |
549 | 554 | ||
@@ -783,10 +788,7 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd) | |||
783 | goto out_dput; | 788 | goto out_dput; |
784 | 789 | ||
785 | if (inode->i_op->follow_link) { | 790 | if (inode->i_op->follow_link) { |
786 | mntget(next.mnt); | ||
787 | err = do_follow_link(&next, nd); | 791 | err = do_follow_link(&next, nd); |
788 | dput(next.dentry); | ||
789 | mntput(next.mnt); | ||
790 | if (err) | 792 | if (err) |
791 | goto return_err; | 793 | goto return_err; |
792 | err = -ENOENT; | 794 | err = -ENOENT; |
@@ -837,10 +839,7 @@ last_component: | |||
837 | inode = next.dentry->d_inode; | 839 | inode = next.dentry->d_inode; |
838 | if ((lookup_flags & LOOKUP_FOLLOW) | 840 | if ((lookup_flags & LOOKUP_FOLLOW) |
839 | && inode && inode->i_op && inode->i_op->follow_link) { | 841 | && inode && inode->i_op && inode->i_op->follow_link) { |
840 | mntget(next.mnt); | ||
841 | err = do_follow_link(&next, nd); | 842 | err = do_follow_link(&next, nd); |
842 | dput(next.dentry); | ||
843 | mntput(next.mnt); | ||
844 | if (err) | 843 | if (err) |
845 | goto return_err; | 844 | goto return_err; |
846 | inode = nd->dentry->d_inode; | 845 | inode = nd->dentry->d_inode; |