diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2020-01-26 10:06:13 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2020-03-13 21:09:12 -0400 |
commit | 3ad5615a071f7c1c41b2e23b9ffde73b09499eb0 (patch) | |
tree | db900952b30b92270b9eced6a7ee3d3e787023a5 | |
parent | 7be219b4dcd9c698a120726e48a52b96f554fd2c (diff) | |
download | linux-stable-3ad5615a071f7c1c41b2e23b9ffde73b09499eb0.tar.gz linux-stable-3ad5615a071f7c1c41b2e23b9ffde73b09499eb0.tar.bz2 linux-stable-3ad5615a071f7c1c41b2e23b9ffde73b09499eb0.zip |
do_last(): merge the may_open() calls
have FMODE_OPENED case rejoin the main path at earlier point
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/namei.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/fs/namei.c b/fs/namei.c index 7e932d9a71a9..2f8a5d3be784 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3207,10 +3207,7 @@ static const char *do_last(struct nameidata *nd, audit_inode(nd->name, file->f_path.dentry, 0); dput(nd->path.dentry); nd->path.dentry = dentry; - error = may_open(&nd->path, acc_mode, open_flag); - if (error) - goto out; - goto opened; + goto finish_open_created; } if (file->f_mode & FMODE_CREATED) { @@ -3277,11 +3274,10 @@ finish_open_created: error = may_open(&nd->path, acc_mode, open_flag); if (error) goto out; - BUG_ON(file->f_mode & FMODE_OPENED); /* once it's opened, it's opened */ - error = vfs_open(&nd->path, file); + if (!(file->f_mode & FMODE_OPENED)) + error = vfs_open(&nd->path, file); if (error) goto out; -opened: error = ima_file_check(file, op->acc_mode); if (!error && will_truncate) error = handle_truncate(file); |