Commit f20877d9 authored by J. R. Okajima's avatar J. R. Okajima Committed by Nick Piggin

fs: fix do_last error case when need_reval_dot

When open(2) without O_DIRECTORY opens an existing dir, it should return
EISDIR. In do_last(), the variable 'error' is initialized EISDIR, but it
is changed by d_revalidate() which returns any positive to represent
'the target dir is valid.'

Should we keep and return the initialized 'error' in this case.
Signed-off-by: default avatarNick Piggin <npiggin@kernel.dk>
parent 657e94b6
...@@ -2122,12 +2122,14 @@ static struct file *do_last(struct nameidata *nd, struct path *path, ...@@ -2122,12 +2122,14 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
dir = nd->path.dentry; dir = nd->path.dentry;
case LAST_DOT: case LAST_DOT:
if (need_reval_dot(dir)) { if (need_reval_dot(dir)) {
error = d_revalidate(nd->path.dentry, nd); int status = d_revalidate(nd->path.dentry, nd);
if (!error) if (!status)
error = -ESTALE; status = -ESTALE;
if (error < 0) if (status < 0) {
error = status;
goto exit; goto exit;
} }
}
/* fallthrough */ /* fallthrough */
case LAST_ROOT: case LAST_ROOT:
goto exit; goto exit;
......
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