Commit cd4e91d3 authored by Al Viro's avatar Al Viro Committed by Linus Torvalds

[PATCH] namei fixes (7/19)

The first argument of __do_follow_link() switched to struct path *
(__do_follow_link(path->dentry, ...) -> __do_follow_link(path, ...)).

All callers have the same calls of mntget() right before and dput()/mntput()
right after __do_follow_link(); these calls have been moved inside.

Obviously equivalent transformations.
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 839d9f93
...@@ -498,12 +498,15 @@ struct path { ...@@ -498,12 +498,15 @@ struct path {
struct dentry *dentry; struct dentry *dentry;
}; };
static inline int __do_follow_link(struct dentry *dentry, struct nameidata *nd) static inline int __do_follow_link(struct path *path, struct nameidata *nd)
{ {
int error; int error;
struct dentry *dentry = path->dentry;
touch_atime(nd->mnt, dentry); touch_atime(nd->mnt, dentry);
nd_set_link(nd, NULL); nd_set_link(nd, NULL);
mntget(path->mnt);
error = dentry->d_inode->i_op->follow_link(dentry, nd); error = dentry->d_inode->i_op->follow_link(dentry, nd);
if (!error) { if (!error) {
char *s = nd_get_link(nd); char *s = nd_get_link(nd);
...@@ -512,6 +515,8 @@ static inline int __do_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -512,6 +515,8 @@ static inline int __do_follow_link(struct dentry *dentry, struct nameidata *nd)
if (dentry->d_inode->i_op->put_link) if (dentry->d_inode->i_op->put_link)
dentry->d_inode->i_op->put_link(dentry, nd); dentry->d_inode->i_op->put_link(dentry, nd);
} }
dput(dentry);
mntput(path->mnt);
return error; return error;
} }
...@@ -538,10 +543,7 @@ static inline int do_follow_link(struct path *path, struct nameidata *nd) ...@@ -538,10 +543,7 @@ static inline int do_follow_link(struct path *path, struct nameidata *nd)
current->link_count++; current->link_count++;
current->total_link_count++; current->total_link_count++;
nd->depth++; nd->depth++;
mntget(path->mnt); err = __do_follow_link(path, nd);
err = __do_follow_link(path->dentry, nd);
dput(path->dentry);
mntput(path->mnt);
current->link_count--; current->link_count--;
nd->depth--; nd->depth--;
return err; return err;
...@@ -1523,10 +1525,7 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) ...@@ -1523,10 +1525,7 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
error = security_inode_follow_link(path.dentry, nd); error = security_inode_follow_link(path.dentry, nd);
if (error) if (error)
goto exit_dput; goto exit_dput;
mntget(path.mnt); error = __do_follow_link(&path, nd);
error = __do_follow_link(path.dentry, nd);
dput(path.dentry);
mntput(path.mnt);
path.mnt = nd->mnt; path.mnt = nd->mnt;
if (error) if (error)
return error; return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment