aboutsummaryrefslogtreecommitdiffstats
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
parent391172c46e6f9d5d03855ff3ae5720d9826f3b59 (diff)
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>
-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,
3403 int error; 3403 int error;
3404 bool is_dir = (lookup_flags & LOOKUP_DIRECTORY); 3404 bool is_dir = (lookup_flags & LOOKUP_DIRECTORY);
3405 3405
3406 if (IS_ERR(name))
3407 return ERR_CAST(name);
3406 /* 3408 /*
3407 * Note that only LOOKUP_REVAL and LOOKUP_DIRECTORY matter here. Any 3409 * Note that only LOOKUP_REVAL and LOOKUP_DIRECTORY matter here. Any
3408 * other flags passed in are ignored! 3410 * other flags passed in are ignored!
@@ -3410,8 +3412,10 @@ static struct dentry *filename_create(int dfd, struct filename *name,
3410 lookup_flags &= LOOKUP_REVAL; 3412 lookup_flags &= LOOKUP_REVAL;
3411 3413
3412 error = filename_parentat(dfd, name, lookup_flags, path, &last, &type); 3414 error = filename_parentat(dfd, name, lookup_flags, path, &last, &type);
3413 if (error) 3415 if (error) {
3416 putname(name);
3414 return ERR_PTR(error); 3417 return ERR_PTR(error);
3418 }
3415 3419
3416 /* 3420 /*
3417 * Yucky last component or no last component at all? 3421 * Yucky last component or no last component at all?
@@ -3449,6 +3453,7 @@ static struct dentry *filename_create(int dfd, struct filename *name,
3449 error = err2; 3453 error = err2;
3450 goto fail; 3454 goto fail;
3451 } 3455 }
3456 putname(name);
3452 return dentry; 3457 return dentry;
3453fail: 3458fail:
3454 dput(dentry); 3459 dput(dentry);
@@ -3459,20 +3464,15 @@ unlock:
3459 mnt_drop_write(path->mnt); 3464 mnt_drop_write(path->mnt);
3460out: 3465out:
3461 path_put(path); 3466 path_put(path);
3467 putname(name);
3462 return dentry; 3468 return dentry;
3463} 3469}
3464 3470
3465struct dentry *kern_path_create(int dfd, const char *pathname, 3471struct dentry *kern_path_create(int dfd, const char *pathname,
3466 struct path *path, unsigned int lookup_flags) 3472 struct path *path, unsigned int lookup_flags)
3467{ 3473{
3468 struct filename *filename = getname_kernel(pathname); 3474 return filename_create(dfd, getname_kernel(pathname),
3469 struct dentry *res; 3475 path, lookup_flags);
3470
3471 if (IS_ERR(filename))
3472 return ERR_CAST(filename);
3473 res = filename_create(dfd, filename, path, lookup_flags);
3474 putname(filename);
3475 return res;
3476} 3476}
3477EXPORT_SYMBOL(kern_path_create); 3477EXPORT_SYMBOL(kern_path_create);
3478 3478
@@ -3488,13 +3488,7 @@ EXPORT_SYMBOL(done_path_create);
3488struct dentry *user_path_create(int dfd, const char __user *pathname, 3488struct dentry *user_path_create(int dfd, const char __user *pathname,
3489 struct path *path, unsigned int lookup_flags) 3489 struct path *path, unsigned int lookup_flags)
3490{ 3490{
3491 struct filename *tmp = getname(pathname); 3491 return filename_create(dfd, getname(pathname), path, lookup_flags);
3492 struct dentry *res;
3493 if (IS_ERR(tmp))
3494 return ERR_CAST(tmp);
3495 res = filename_create(dfd, tmp, path, lookup_flags);
3496 putname(tmp);
3497 return res;
3498} 3492}
3499EXPORT_SYMBOL(user_path_create); 3493EXPORT_SYMBOL(user_path_create);
3500 3494