summaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-05-12 17:21:25 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-05-15 01:10:42 -0400
commit181c37b6e4c1bdb061ed0d884c54f9a6e6cdac89 (patch)
treea0fce3617f10ca1a4ac1957d53741837164293ea /fs/namei.c
parent391172c46e6f9d5d03855ff3ae5720d9826f3b59 (diff)
downloadlinux-181c37b6e4c1bdb061ed0d884c54f9a6e6cdac89.tar.bz2
namei: saner calling conventions for filename_create()
a) make it reject ERR_PTR() for name b) make it putname(name) upon return in all other cases. seriously simplifies the callers... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 593cf3b01e74..628b6eb9415f 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3403,6 +3403,8 @@ static struct dentry *filename_create(int dfd, struct filename *name,
int error;
bool is_dir = (lookup_flags & LOOKUP_DIRECTORY);
+ if (IS_ERR(name))
+ return ERR_CAST(name);
/*
* Note that only LOOKUP_REVAL and LOOKUP_DIRECTORY matter here. Any
* other flags passed in are ignored!
@@ -3410,8 +3412,10 @@ static struct dentry *filename_create(int dfd, struct filename *name,
lookup_flags &= LOOKUP_REVAL;
error = filename_parentat(dfd, name, lookup_flags, path, &last, &type);
- if (error)
+ if (error) {
+ putname(name);
return ERR_PTR(error);
+ }
/*
* Yucky last component or no last component at all?
@@ -3449,6 +3453,7 @@ static struct dentry *filename_create(int dfd, struct filename *name,
error = err2;
goto fail;
}
+ putname(name);
return dentry;
fail:
dput(dentry);
@@ -3459,20 +3464,15 @@ unlock:
mnt_drop_write(path->mnt);
out:
path_put(path);
+ putname(name);
return dentry;
}
struct dentry *kern_path_create(int dfd, const char *pathname,
struct path *path, unsigned int lookup_flags)
{
- struct filename *filename = getname_kernel(pathname);
- struct dentry *res;
-
- if (IS_ERR(filename))
- return ERR_CAST(filename);
- res = filename_create(dfd, filename, path, lookup_flags);
- putname(filename);
- return res;
+ return filename_create(dfd, getname_kernel(pathname),
+ path, lookup_flags);
}
EXPORT_SYMBOL(kern_path_create);
@@ -3488,13 +3488,7 @@ EXPORT_SYMBOL(done_path_create);
struct dentry *user_path_create(int dfd, const char __user *pathname,
struct path *path, unsigned int lookup_flags)
{
- struct filename *tmp = getname(pathname);
- struct dentry *res;
- if (IS_ERR(tmp))
- return ERR_CAST(tmp);
- res = filename_create(dfd, tmp, path, lookup_flags);
- putname(tmp);
- return res;
+ return filename_create(dfd, getname(pathname), path, lookup_flags);
}
EXPORT_SYMBOL(user_path_create);