diff options
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/fs/namei.c b/fs/namei.c index 6a884682b0a7..444086d441e1 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -506,7 +506,8 @@ static inline int __do_follow_link(struct path *path, struct nameidata *nd) | |||
506 | touch_atime(nd->mnt, dentry); | 506 | touch_atime(nd->mnt, dentry); |
507 | nd_set_link(nd, NULL); | 507 | nd_set_link(nd, NULL); |
508 | 508 | ||
509 | mntget(path->mnt); | 509 | if (path->mnt == nd->mnt) |
510 | mntget(path->mnt); | ||
510 | error = dentry->d_inode->i_op->follow_link(dentry, nd); | 511 | error = dentry->d_inode->i_op->follow_link(dentry, nd); |
511 | if (!error) { | 512 | if (!error) { |
512 | char *s = nd_get_link(nd); | 513 | char *s = nd_get_link(nd); |
@@ -543,8 +544,6 @@ static inline int do_follow_link(struct path *path, struct nameidata *nd) | |||
543 | current->link_count++; | 544 | current->link_count++; |
544 | current->total_link_count++; | 545 | current->total_link_count++; |
545 | nd->depth++; | 546 | nd->depth++; |
546 | if (path->mnt != nd->mnt) | ||
547 | mntput(path->mnt); | ||
548 | err = __do_follow_link(path, nd); | 547 | err = __do_follow_link(path, nd); |
549 | current->link_count--; | 548 | current->link_count--; |
550 | nd->depth--; | 549 | nd->depth--; |
@@ -1550,8 +1549,6 @@ do_link: | |||
1550 | error = security_inode_follow_link(path.dentry, nd); | 1549 | error = security_inode_follow_link(path.dentry, nd); |
1551 | if (error) | 1550 | if (error) |
1552 | goto exit_dput; | 1551 | goto exit_dput; |
1553 | if (nd->mnt != path.mnt) | ||
1554 | mntput(path.mnt); | ||
1555 | error = __do_follow_link(&path, nd); | 1552 | error = __do_follow_link(&path, nd); |
1556 | if (error) | 1553 | if (error) |
1557 | return error; | 1554 | return error; |