summaryrefslogtreecommitdiff
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-04-27 10:14:20 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2016-05-03 02:51:13 +0300
commitfe9ec8291fcaa74badf0a67e3a82741b3ee40a9e (patch)
tree64c88e278d6171fcd759c495eb90c3cd1bf6abb4 /fs/namei.c
parent47f9dbd3877d9d9757366278a65d9fb3de5c1c4e (diff)
downloadlinux-fe9ec8291fcaa74badf0a67e3a82741b3ee40a9e.tar.xz
do_last(): take fput() on error after opening to out:
make it conditional on *opened & FILE_OPENED; in addition to getting rid of exit_fput: thing, it simplifies atomic_open() cleanup on may_open() failure. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 6503767746f6..38eab154cef7 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2919,9 +2919,6 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
acc_mode = 0;
}
error = may_open(&file->f_path, acc_mode, open_flag);
- if (error)
- fput(file);
-
out:
dput(dentry);
return error;
@@ -3225,18 +3222,13 @@ finish_open_created:
}
opened:
error = open_check_o_direct(file);
- if (error)
- goto exit_fput;
- error = ima_file_check(file, op->acc_mode, *opened);
- if (error)
- goto exit_fput;
-
- if (will_truncate) {
+ if (!error)
+ error = ima_file_check(file, op->acc_mode, *opened);
+ if (!error && will_truncate)
error = handle_truncate(file);
- if (error)
- goto exit_fput;
- }
out:
+ if (unlikely(error) && (*opened & FILE_OPENED))
+ fput(file);
if (unlikely(error > 0)) {
WARN_ON(1);
error = -EINVAL;
@@ -3246,10 +3238,6 @@ out:
path_put(&save_parent);
return error;
-exit_fput:
- fput(file);
- goto out;
-
stale_open:
/* If no saved parent or already retried then can't retry */
if (!save_parent.dentry || retried)