From: hyeongseok.kim Date: Thu, 4 Jun 2020 04:54:28 +0000 (+0900) Subject: exfat: fix range validation error in alloc and free cluster X-Git-Tag: v5.10.7~2382^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a949824f01f3b39f737d77aed6cba47aced09319;p=platform%2Fkernel%2Flinux-rpi.git exfat: fix range validation error in alloc and free cluster There is check error in range condition that can never be entered even with invalid input. Replace incorrent checking code with already existing valid checker. Signed-off-by: hyeongseok.kim Acked-by: Sungjong Seo Signed-off-by: Namjae Jeon --- diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c index 267e5e09eb13..4e5c5c9c0f2d 100644 --- a/fs/exfat/fatent.c +++ b/fs/exfat/fatent.c @@ -169,7 +169,7 @@ int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain) return 0; /* check cluster validation */ - if (p_chain->dir < 2 && p_chain->dir >= sbi->num_clusters) { + if (!is_valid_cluster(sbi, p_chain->dir)) { exfat_err(sb, "invalid start cluster (%u)", p_chain->dir); return -EIO; } @@ -346,7 +346,7 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc, } /* check cluster validation */ - if (hint_clu < EXFAT_FIRST_CLUSTER && hint_clu >= sbi->num_clusters) { + if (!is_valid_cluster(sbi, hint_clu)) { exfat_err(sb, "hint_cluster is invalid (%u)", hint_clu); hint_clu = EXFAT_FIRST_CLUSTER;