diff options
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/namei.c b/fs/namei.c index 0a601cae23de..b912b7abe747 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -753,9 +753,11 @@ follow_link(struct path *link, struct nameidata *nd, void **p) | |||
753 | 753 | ||
754 | BUG_ON(nd->flags & LOOKUP_RCU); | 754 | BUG_ON(nd->flags & LOOKUP_RCU); |
755 | 755 | ||
756 | if (link->mnt == nd->path.mnt) | ||
757 | mntget(link->mnt); | ||
758 | |||
756 | if (unlikely(current->total_link_count >= 40)) { | 759 | if (unlikely(current->total_link_count >= 40)) { |
757 | *p = ERR_PTR(-ELOOP); /* no ->put_link(), please */ | 760 | *p = ERR_PTR(-ELOOP); /* no ->put_link(), please */ |
758 | path_put_conditional(link, nd); | ||
759 | path_put(&nd->path); | 761 | path_put(&nd->path); |
760 | return -ELOOP; | 762 | return -ELOOP; |
761 | } | 763 | } |
@@ -765,9 +767,6 @@ follow_link(struct path *link, struct nameidata *nd, void **p) | |||
765 | touch_atime(link->mnt, dentry); | 767 | touch_atime(link->mnt, dentry); |
766 | nd_set_link(nd, NULL); | 768 | nd_set_link(nd, NULL); |
767 | 769 | ||
768 | if (link->mnt == nd->path.mnt) | ||
769 | mntget(link->mnt); | ||
770 | |||
771 | error = security_inode_follow_link(link->dentry, nd); | 770 | error = security_inode_follow_link(link->dentry, nd); |
772 | if (error) { | 771 | if (error) { |
773 | *p = ERR_PTR(error); /* no ->put_link(), please */ | 772 | *p = ERR_PTR(error); /* no ->put_link(), please */ |