diff options
-rw-r--r-- | fs/cifs/readdir.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 1f0bd0f972d4..6f3d13ff9470 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c @@ -790,6 +790,17 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir) cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); + /* + * Ensure FindFirst doesn't fail before doing filldir() for '.' and + * '..'. Otherwise we won't be able to notify VFS in case of failure. + */ + if (file->private_data == NULL) { + rc = initiate_cifs_search(xid, file); + cFYI(1, "initiate cifs search rc %d", rc); + if (rc) + goto rddir2_exit; + } + switch ((int) file->f_pos) { case 0: if (filldir(direntry, ".", 1, file->f_pos, @@ -814,14 +825,6 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir) if after then keep searching till find it */ if (file->private_data == NULL) { - rc = initiate_cifs_search(xid, file); - cFYI(1, "initiate cifs search rc %d", rc); - if (rc) { - FreeXid(xid); - return rc; - } - } - if (file->private_data == NULL) { rc = -EINVAL; FreeXid(xid); return rc; |