exfat: fix overflow issue in exfat_cluster_to_sector()

An overflow issue can occur at sector calculation in
exfat_cluster_to_sector(). It needs to cast clus's type to sector_t
before left shifting.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
Namjae Jeon 2020-07-03 08:10:27 +09:00 • committed by Namjae Jeon
commit 9cbc7e418e

View file

@ -381,7 +381,7 @@ static inline bool exfat_is_last_sector_in_cluster(struct exfat_sb_info *sbi,
static inline sector_t exfat_cluster_to_sector(struct exfat_sb_info *sbi,
unsigned int clus)
{
return ((clus - EXFAT_RESERVED_CLUSTERS) << sbi->sect_per_clus_bits) +
return ((sector_t)(clus - EXFAT_RESERVED_CLUSTERS) << sbi->sect_per_clus_bits) +
sbi->data_start_sector;
}