diff --git a/balloc.c b/balloc.c index c6807392183e..a7a24acd39cc 100644 --- a/balloc.c +++ b/balloc.c @@ -7,7 +7,7 @@ #include #include #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) #include #endif diff --git a/dir.c b/dir.c index 565cc34829f3..61d49a328812 100644 --- a/dir.c +++ b/dir.c @@ -64,7 +64,7 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb, static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_entry *dir_entry) { int i, dentries_per_clu, dentries_per_clu_bits = 0, num_ext; - unsigned int type, clu_offset; + unsigned int type, clu_offset, max_dentries; sector_t sector; struct exfat_chain dir, clu; struct exfat_uni_name uni_name; @@ -87,6 +87,8 @@ static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_ent dentries_per_clu = sbi->dentries_per_clu; dentries_per_clu_bits = ilog2(dentries_per_clu); + max_dentries = (unsigned int)min_t(u64, MAX_EXFAT_DENTRIES, + (u64)sbi->num_clusters << dentries_per_clu_bits); clu_offset = dentry >> dentries_per_clu_bits; exfat_chain_dup(&clu, &dir); @@ -110,7 +112,7 @@ static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_ent } } - while (clu.dir != EXFAT_EOF_CLUSTER) { + while (clu.dir != EXFAT_EOF_CLUSTER && dentry < max_dentries) { i = dentry & (dentries_per_clu - 1); for ( ; i < dentries_per_clu; i++, dentry++) { @@ -246,7 +248,7 @@ static int exfat_iterate(struct file *filp, struct dir_context *ctx) if (err) goto unlock; get_new: - if (cpos >= i_size_read(inode)) + if (ei->flags == ALLOC_NO_FAT_CHAIN && cpos >= i_size_read(inode)) goto end_of_dir; err = exfat_readdir(inode, &cpos, &de); diff --git a/exfat_fs.h b/exfat_fs.h index b3db5a8217c8..69b8793b5eb0 100644 --- a/exfat_fs.h +++ b/exfat_fs.h @@ -11,7 +11,7 @@ #include #include -#define EXFAT_VERSION "5.12.3" +#define EXFAT_VERSION "5.14.1" #define EXFAT_SUPER_MAGIC 0x2011BAB0UL #define EXFAT_ROOT_INO 1 diff --git a/misc.c b/misc.c index b9fed54901d1..9d81e803c442 100644 --- a/misc.c +++ b/misc.c @@ -119,6 +119,8 @@ void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec *ts, void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts, u8 *tz, __le16 *time, __le16 *date, u8 *time_cs) #else +#undef EXFAT_MAX_TIMESTAMP_SECS +#define EXFAT_MAX_TIMESTAMP_SECS 0xffffffff void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec *ts, u8 *tz, __le16 *time, __le16 *date, u8 *time_cs) #endif diff --git a/super.c b/super.c index 7d5651decef2..8d0832a56ea0 100644 --- a/super.c +++ b/super.c @@ -984,7 +984,7 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent) if (!sb->s_root) { exfat_err(sb, "failed to get the root dentry"); err = -ENOMEM; - goto put_inode; + goto free_table; } return 0;