fs: fix do_last error case when need_reval_dot
authorJ. R. Okajima <hooanon05@yahoo.co.jp>
Fri, 14 Jan 2011 03:56:04 +0000 (03:56 +0000)
committerNick Piggin <npiggin@kernel.dk>
Fri, 14 Jan 2011 03:56:04 +0000 (03:56 +0000)
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 <npiggin@kernel.dk>
fs/namei.c

index 14c73edca9ce27ca342af4a297b5dc522539e69b..bc24894c5f14ebc330e73a4347db9a49022f0a7a 100644 (file)
@@ -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: