@@ -157,6 +157,7 @@ static int __exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain
struct super_block *sb = inode->i_sb;
struct exfat_sb_info *sbi = EXFAT_SB(sb);
int cur_cmap_i, next_cmap_i;
+ int chain_i;
unsigned int num_clusters = 0;
unsigned int clu;
@@ -176,6 +177,13 @@ static int __exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain
return -EIO;
}
+ /* check size */
+ chain_i = BITMAP_OFFSET_SECTOR_INDEX(sb,
+ CLUSTER_TO_BITMAP_ENT(p_chain->size + p_chain->dir));
+ if (chain_i > sbi->map_sectors) {
+ exfat_err(sb, "invalid start size (%u)", p_chain->size);
+ return -EIO;
+ }
+
clu = p_chain->dir;
cur_cmap_i = next_cmap_i =