summaryrefslogtreecommitdiff
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2020-03-11 13:05:03 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2020-03-13 21:09:13 -0400
commita6a7eb7628cfa7e0e8f62e185502facc43bd2ce3 (patch)
tree02ae22142752f09835e6560804ca15fa779cb7cf /fs/namei.c
parent63b27720a476e99d3eaceee9d2246459ae0f6286 (diff)
expand path_parent_directory() in its callers
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 49b2a08105c7..88e5d7920540 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1440,18 +1440,6 @@ static void follow_mount(struct path *path)
}
}
-static struct dentry *path_parent_directory(struct path *path)
-{
- /* rare case of legitimate dget_parent()... */
- struct dentry *parent = dget_parent(path->dentry);
-
- if (unlikely(!path_connected(path->mnt, parent))) {
- dput(parent);
- parent = NULL;
- }
- return parent;
-}
-
static int follow_dotdot(struct nameidata *nd)
{
struct dentry *parent;
@@ -1462,9 +1450,13 @@ static int follow_dotdot(struct nameidata *nd)
break;
}
if (nd->path.dentry != nd->path.mnt->mnt_root) {
- parent = path_parent_directory(&nd->path);
- if (!parent)
+ /* rare case of legitimate dget_parent()... */
+ parent = dget_parent(nd->path.dentry);
+
+ if (unlikely(!path_connected(nd->path.mnt, parent))) {
+ dput(parent);
return -ENOENT;
+ }
dput(nd->path.dentry);
nd->path.dentry = parent;
break;
@@ -2602,13 +2594,14 @@ int path_pts(struct path *path)
/* Find something mounted on "pts" in the same directory as
* the input path.
*/
- struct dentry *child, *parent;
+ struct dentry *parent = dget_parent(path->dentry);
+ struct dentry *child;
struct qstr this;
- parent = path_parent_directory(path);
- if (!parent)
+ if (unlikely(!path_connected(path->mnt, parent))) {
+ dput(parent);
return -ENOENT;
-
+ }
dput(path->dentry);
path->dentry = parent;
this.name = "pts";