Commit a949824f authored by hyeongseok.kim's avatar hyeongseok.kim Committed by Namjae Jeon

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: default avatarhyeongseok.kim <hyeongseok@gmail.com>
Acked-by: default avatarSungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: default avatarNamjae Jeon <namjae.jeon@samsung.com>
parent 29bbb14b
...@@ -169,7 +169,7 @@ int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain) ...@@ -169,7 +169,7 @@ int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain)
return 0; return 0;
/* check cluster validation */ /* 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); exfat_err(sb, "invalid start cluster (%u)", p_chain->dir);
return -EIO; return -EIO;
} }
...@@ -346,7 +346,7 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc, ...@@ -346,7 +346,7 @@ int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
} }
/* check cluster validation */ /* 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)", exfat_err(sb, "hint_cluster is invalid (%u)",
hint_clu); hint_clu);
hint_clu = EXFAT_FIRST_CLUSTER; hint_clu = EXFAT_FIRST_CLUSTER;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment