From patchwork Fri Oct 1 15:53:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suresh Jayaraman X-Patchwork-Id: 224392 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o91FnJg7010597 for ; Fri, 1 Oct 2010 15:53:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751208Ab0JAPxj (ORCPT ); Fri, 1 Oct 2010 11:53:39 -0400 Received: from cantor.suse.de ([195.135.220.2]:55774 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750988Ab0JAPxj (ORCPT ); Fri, 1 Oct 2010 11:53:39 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 7ED10945D6; Fri, 1 Oct 2010 17:53:38 +0200 (CEST) Message-ID: <4CA603FD.6040308@suse.de> Date: Fri, 01 Oct 2010 21:23:33 +0530 From: Suresh Jayaraman User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100714 SUSE/3.0.6 Thunderbird/3.0.6 MIME-Version: 1.0 To: Steve French Cc: linux-cifs Subject: [PATCH] cifs: handle FindFirst failure gracefully Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 01 Oct 2010 15:53:40 +0000 (UTC) diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 887a7e2..edb69a9 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c @@ -786,6 +786,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, @@ -810,14 +821,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;