Commit fe9ec829 authored by Al Viro's avatar Al Viro

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: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 47f9dbd3
...@@ -2919,9 +2919,6 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry, ...@@ -2919,9 +2919,6 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
acc_mode = 0; acc_mode = 0;
} }
error = may_open(&file->f_path, acc_mode, open_flag); error = may_open(&file->f_path, acc_mode, open_flag);
if (error)
fput(file);
out: out:
dput(dentry); dput(dentry);
return error; return error;
...@@ -3225,18 +3222,13 @@ static int do_last(struct nameidata *nd, ...@@ -3225,18 +3222,13 @@ static int do_last(struct nameidata *nd,
} }
opened: opened:
error = open_check_o_direct(file); error = open_check_o_direct(file);
if (error) if (!error)
goto exit_fput; error = ima_file_check(file, op->acc_mode, *opened);
error = ima_file_check(file, op->acc_mode, *opened); if (!error && will_truncate)
if (error)
goto exit_fput;
if (will_truncate) {
error = handle_truncate(file); error = handle_truncate(file);
if (error)
goto exit_fput;
}
out: out:
if (unlikely(error) && (*opened & FILE_OPENED))
fput(file);
if (unlikely(error > 0)) { if (unlikely(error > 0)) {
WARN_ON(1); WARN_ON(1);
error = -EINVAL; error = -EINVAL;
...@@ -3246,10 +3238,6 @@ static int do_last(struct nameidata *nd, ...@@ -3246,10 +3238,6 @@ static int do_last(struct nameidata *nd,
path_put(&save_parent); path_put(&save_parent);
return error; return error;
exit_fput:
fput(file);
goto out;
stale_open: stale_open:
/* If no saved parent or already retried then can't retry */ /* If no saved parent or already retried then can't retry */
if (!save_parent.dentry || retried) if (!save_parent.dentry || retried)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment