Commit 9b44f1b3928b6f41532c9a1dc9a6fc665989ad5b
1 parent
0f9d1a10c3
Exists in
master
and in
4 other branches
move may_open() from __open_name_create() to do_last()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 1 changed file with 7 additions and 5 deletions Side-by-side Diff
fs/namei.c
... | ... | @@ -2069,11 +2069,7 @@ |
2069 | 2069 | mutex_unlock(&dir->d_inode->i_mutex); |
2070 | 2070 | dput(nd->path.dentry); |
2071 | 2071 | nd->path.dentry = path->dentry; |
2072 | - | |
2073 | - if (error) | |
2074 | - return error; | |
2075 | - /* Don't check for write permission, don't truncate */ | |
2076 | - return may_open(&nd->path, 0, open_flag & ~O_TRUNC); | |
2072 | + return error; | |
2077 | 2073 | } |
2078 | 2074 | |
2079 | 2075 | /* |
... | ... | @@ -2235,6 +2231,12 @@ |
2235 | 2231 | if (error) |
2236 | 2232 | goto exit_mutex_unlock; |
2237 | 2233 | error = __open_namei_create(nd, path, op->open_flag, op->mode); |
2234 | + if (error) { | |
2235 | + mnt_drop_write(nd->path.mnt); | |
2236 | + goto exit; | |
2237 | + } | |
2238 | + /* Don't check for write permission, don't truncate */ | |
2239 | + error = may_open(&nd->path, 0, op->open_flag & ~O_TRUNC); | |
2238 | 2240 | if (error) { |
2239 | 2241 | mnt_drop_write(nd->path.mnt); |
2240 | 2242 | goto exit; |