exfat: remove the check for infinite cluster chain loop

The infinite cluster chain loop check is not work because the
loop will terminate when fclus reaches the parameter cluster,
and the parameter cluster value is never greater than
ei->valid_size.

The following relationship holds:
'fclus' < 'cluster' ≤ ei->valid_size ≤ sb->num_clusters

The check would only be triggered if a cluster number greater than
sb->num_clusters is passed, but no caller currently does this.

Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
Chi Zhiling 2026-01-14 20:12:41 +08:00 committed by Namjae Jeon
parent 5e205c484b
commit 2e21557d54

View File

@ -238,8 +238,6 @@ int exfat_get_cluster(struct inode *inode, unsigned int cluster,
unsigned int *last_dclus, int allow_eof)
{
struct super_block *sb = inode->i_sb;
struct exfat_sb_info *sbi = EXFAT_SB(sb);
unsigned int limit = sbi->num_clusters;
struct exfat_inode_info *ei = EXFAT_I(inode);
struct exfat_cache_id cid;
unsigned int content;
@ -279,14 +277,6 @@ int exfat_get_cluster(struct inode *inode, unsigned int cluster,
return 0;
while (*fclus < cluster) {
/* prevent the infinite loop of cluster chain */
if (*fclus > limit) {
exfat_fs_error(sb,
"detected the cluster chain loop (i_pos %u)",
(*fclus));
return -EIO;
}
if (exfat_ent_get(sb, *dclus, &content, NULL))
return -EIO;