diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index a8602729586a..f014b7fed5ce 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -317,7 +317,10 @@ struct nilfs_dir_entry *nilfs_find_entry(struct inode *dir, de = (struct nilfs_dir_entry *)kaddr; kaddr += nilfs_last_byte(dir, n) - reclen; - while ((char *)de <= kaddr) { + printk("isize: %u, n: %lu, last byte: %u, reclen: %u, %s\n", dir->i_size, n, nilfs_last_byte(dir, n), reclen, __func__); + if (nilfs_last_byte(dir, n) < reclen) + break; + while ((char *)de + sizeof(*de) <= kaddr) { if (de->rec_len == 0) { nilfs_error(dir->i_sb, "zero-length directory entry");