Skip to content

Commit

Permalink
[PATCH] namei fixes (12/19)
Browse files Browse the repository at this point in the history
In open_namei() we take mntput(nd->mnt);nd->mnt=path.mnt; out of the if
(__follow_mount(...)), making it conditional on nd->mnt != path.mnt instead.

Then we shift the result downstream.

Equivalent transformations.

Signed-off-by: Al Viro <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Al Viro authored and Linus Torvalds committed Jun 6, 2005
1 parent 2f12dbf commit a15a3f6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,8 +1506,6 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
mntput(path.mnt);
goto exit;
}
mntput(nd->mnt);
nd->mnt = path.mnt;
}
error = -ENOENT;
if (!path.dentry->d_inode)
Expand All @@ -1517,6 +1515,9 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)

dput(nd->dentry);
nd->dentry = path.dentry;
if (nd->mnt != path.mnt)
mntput(nd->mnt);
nd->mnt = path.mnt;
error = -EISDIR;
if (path.dentry->d_inode && S_ISDIR(path.dentry->d_inode->i_mode))
goto exit;
Expand All @@ -1528,6 +1529,9 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)

exit_dput:
dput(path.dentry);
if (nd->mnt != path.mnt)
mntput(nd->mnt);
nd->mnt = path.mnt;
exit:
path_release(nd);
return error;
Expand All @@ -1550,6 +1554,9 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
error = security_inode_follow_link(path.dentry, nd);
if (error)
goto exit_dput;
if (nd->mnt != path.mnt)
mntput(nd->mnt);
nd->mnt = path.mnt;
error = __do_follow_link(&path, nd);
if (error)
return error;
Expand Down

0 comments on commit a15a3f6

Please sign in to comment.