Skip to content

Commit

Permalink
fs: fix do_last error case when need_reval_dot
Browse files Browse the repository at this point in the history
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: Nick Piggin <[email protected]>
  • Loading branch information
J. R. Okajima authored and Nick Piggin committed Jan 14, 2011
1 parent 657e94b commit f20877d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -2122,11 +2122,13 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
dir = nd->path.dentry;
case LAST_DOT:
if (need_reval_dot(dir)) {
error = d_revalidate(nd->path.dentry, nd);
if (!error)
error = -ESTALE;
if (error < 0)
int status = d_revalidate(nd->path.dentry, nd);
if (!status)
status = -ESTALE;
if (status < 0) {
error = status;
goto exit;
}
}
/* fallthrough */
case LAST_ROOT:
Expand Down

0 comments on commit f20877d

Please sign in to comment.