Skip to content

Commit a949824

Browse files
hyeongseok-kim901namjaejeon
authored andcommitted
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 <[email protected]> Acked-by: Sungjong Seo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 29bbb14 commit a949824

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/exfat/fatent.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain)
169169
return 0;
170170

171171
/* check cluster validation */
172-
if (p_chain->dir < 2 && p_chain->dir >= sbi->num_clusters) {
172+
if (!is_valid_cluster(sbi, p_chain->dir)) {
173173
exfat_err(sb, "invalid start cluster (%u)", p_chain->dir);
174174
return -EIO;
175175
}
@@ -346,7 +346,7 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
346346
}
347347

348348
/* check cluster validation */
349-
if (hint_clu < EXFAT_FIRST_CLUSTER && hint_clu >= sbi->num_clusters) {
349+
if (!is_valid_cluster(sbi, hint_clu)) {
350350
exfat_err(sb, "hint_cluster is invalid (%u)",
351351
hint_clu);
352352
hint_clu = EXFAT_FIRST_CLUSTER;

0 commit comments

Comments
 (0)