aboutsummaryrefslogtreecommitdiff
path: root/fs/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/fs/namei.c b/fs/namei.c
index c9b05a71c39..b0df7ea733d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -362,11 +362,18 @@ int deny_write_access(struct file * file)
return 0;
}
-void path_release(struct nameidata *nd)
+/**
+ * path_put - put a reference to a path
+ * @path: path to put the reference to
+ *
+ * Given a path decrement the reference count to the dentry and the vfsmount.
+ */
+void path_put(struct path *path)
{
- dput(nd->path.dentry);
- mntput(nd->path.mnt);
+ dput(path->dentry);
+ mntput(path->mnt);
}
+EXPORT_SYMBOL(path_put);
/**
* release_open_intent - free up open intent resources
@@ -551,7 +558,7 @@ static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *l
goto fail;
if (*link == '/') {
- path_release(nd);
+ path_put(&nd->path);
if (!walk_init_root(link, nd))
/* weird __emul_prefix() stuff did it */
goto out;
@@ -567,18 +574,18 @@ out:
*/
name = __getname();
if (unlikely(!name)) {
- path_release(nd);
+ path_put(&nd->path);
return -ENOMEM;
}
strcpy(name, nd->last.name);
nd->last.name = name;
return 0;
fail:
- path_release(nd);
+ path_put(&nd->path);
return PTR_ERR(link);
}
-static inline void dput_path(struct path *path, struct nameidata *nd)
+static void path_put_conditional(struct path *path, struct nameidata *nd)
{
dput(path->dentry);
if (path->mnt != nd->path.mnt)
@@ -651,8 +658,8 @@ static inline int do_follow_link(struct path *path, struct nameidata *nd)
nd->depth--;
return err;
loop:
- dput_path(path, nd);
- path_release(nd);
+ path_put_conditional(path, nd);
+ path_put(&nd->path);
return err;
}
@@ -993,10 +1000,10 @@ return_reval:
return_base:
return 0;
out_dput:
- dput_path(&next, nd);
+ path_put_conditional(&next, nd);
break;
}
- path_release(nd);
+ path_put(&nd->path);
return_err:
return err;
}
@@ -1070,7 +1077,7 @@ static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
mntput(old_mnt);
return 1;
}
- path_release(nd);
+ path_put(&nd->path);
}
nd->path.dentry = old_dentry;
nd->path.mnt = old_mnt;
@@ -1230,7 +1237,7 @@ static int __path_lookup_intent_open(int dfd, const char *name,
if (IS_ERR(nd->intent.open.file)) {
if (err == 0) {
err = PTR_ERR(nd->intent.open.file);
- path_release(nd);
+ path_put(&nd->path);
}
} else if (err != 0)
release_open_intent(nd);
@@ -1806,11 +1813,11 @@ ok:
return 0;
exit_dput:
- dput_path(&path, nd);
+ path_put_conditional(&path, nd);
exit:
if (!IS_ERR(nd->intent.open.file))
release_open_intent(nd);
- path_release(nd);
+ path_put(&nd->path);
return error;
do_link:
@@ -1979,7 +1986,7 @@ asmlinkage long sys_mknodat(int dfd, const char __user *filename, int mode,
dput(dentry);
}
mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
- path_release(&nd);
+ path_put(&nd.path);
out:
putname(tmp);
@@ -2039,7 +2046,7 @@ asmlinkage long sys_mkdirat(int dfd, const char __user *pathname, int mode)
dput(dentry);
out_unlock:
mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
- path_release(&nd);
+ path_put(&nd.path);
out:
putname(tmp);
out_err:
@@ -2147,7 +2154,7 @@ static long do_rmdir(int dfd, const char __user *pathname)
exit2:
mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
exit1:
- path_release(&nd);
+ path_put(&nd.path);
exit:
putname(name);
return error;
@@ -2231,7 +2238,7 @@ static long do_unlinkat(int dfd, const char __user *pathname)
if (inode)
iput(inode); /* truncate the inode here */
exit1:
- path_release(&nd);
+ path_put(&nd.path);
exit:
putname(name);
return error;
@@ -2308,7 +2315,7 @@ asmlinkage long sys_symlinkat(const char __user *oldname,
dput(dentry);
out_unlock:
mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
- path_release(&nd);
+ path_put(&nd.path);
out:
putname(to);
out_putname:
@@ -2404,9 +2411,9 @@ asmlinkage long sys_linkat(int olddfd, const char __user *oldname,
out_unlock:
mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
out_release:
- path_release(&nd);
+ path_put(&nd.path);
out:
- path_release(&old_nd);
+ path_put(&old_nd.path);
exit:
putname(to);
@@ -2634,9 +2641,9 @@ exit4:
exit3:
unlock_rename(new_dir, old_dir);
exit2:
- path_release(&newnd);
+ path_put(&newnd.path);
exit1:
- path_release(&oldnd);
+ path_put(&oldnd.path);
exit:
return error;
}
@@ -2810,7 +2817,6 @@ EXPORT_SYMBOL(page_symlink);
EXPORT_SYMBOL(page_symlink_inode_operations);
EXPORT_SYMBOL(path_lookup);
EXPORT_SYMBOL(vfs_path_lookup);
-EXPORT_SYMBOL(path_release);
EXPORT_SYMBOL(permission);
EXPORT_SYMBOL(vfs_permission);
EXPORT_SYMBOL(file_permission);