Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752628AbcD0MYc (ORCPT ); Wed, 27 Apr 2016 08:24:32 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:63033 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751798AbcD0MYa (ORCPT ); Wed, 27 Apr 2016 08:24:30 -0400 From: Yunlong Song To: , , , , , CC: , , , , , , Subject: [PATCH] f2fs: fix to return 0 if err == -ENOENT in f2fs_readdir Date: Wed, 27 Apr 2016 20:32:37 +0800 Message-ID: <1461760357-13882-1-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.4.5 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.110.52.30] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090205.5720AF67.01D7,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: e94a1aee586a83b3b062f77efe2f9a44 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 898 Lines: 29 Commit 57b62d29ad5b384775974973087d47755a8c6fcc ("f2fs: fix to report error in f2fs_readdir") causes f2fs_readdir to return -ENOENT when get_lock_data_page returns -ENOENT. However, the original logic is to continue when get_lock_data_page returns -ENOENT, but it forgets to reset err to 0. This will cause getdents64 incorretly return -ENOENT when lastdirent is NULL in getdents64. This will lead to a wrong return value for syscall caller. Signed-off-by: Yunlong Song --- fs/f2fs/dir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 0ad7b9a..3ed6145 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -886,6 +886,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx) kunmap(dentry_page); f2fs_put_page(dentry_page, 1); } + err = 0; out: fscrypt_fname_free_buffer(&fstr); return err; -- 1.8.5.2