diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 07ad850bbf97f5f975382f6d8ac6bc5100e3ae0b..f0b463049444218c789c76aebc139f2ed45d279c 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -190,9 +190,6 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir, unsigned int max_depth; unsigned int level; - if (unlikely(namelen > F2FS_NAME_LEN)) - return NULL; - if (npages == 0) return NULL; diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index a3f4542160cf1abb099a94419afe2bb19bfd56b9..4d411a26b85d547f1ca05f23af7de6f2424a4518 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c @@ -62,6 +62,12 @@ static int recover_dentry(struct page *ipage, struct inode *inode) name.len = le32_to_cpu(raw_inode->i_namelen); name.name = raw_inode->i_name; + + if (unlikely(name.len > F2FS_NAME_LEN)) { + WARN_ON(1); + err = -ENAMETOOLONG; + goto out; + } retry: de = f2fs_find_entry(dir, &name, &page); if (de && inode->i_ino == le32_to_cpu(de->ino))