From 90e54784370f706105f7bc1debcd04470ad26db2 Mon Sep 17 00:00:00 2001 From: Yuezhang Mo Date: Thu, 28 Jul 2022 10:01:26 +0800 Subject: [PATCH] BACKPORT: exfat: fix overflow for large capacity partition Using int type for sector index, there will be overflow in a large capacity partition. For example, if storage with sector size of 512 bytes and partition capacity is larger than 2TB, there will be overflow. Bug: 254441685 Fixes: 1b6138385499 ("exfat: reduce block requests when zeroing a cluster") Cc: stable@vger.kernel.org # v5.19+ Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru Acked-by: Sungjong Seo Signed-off-by: Namjae Jeon (cherry picked from commit 2e9ceb6728f1dc2fa4b5d08f37d88cbc49a20a62) Signed-off-by: Lee Jones Change-Id: I0ebd4d6d3ac9e0e5b50f58a62e5b49ef4959b3e3 --- fs/exfat/fatent.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c index 84b2885b8741..7bd425dd4864 100644 --- a/fs/exfat/fatent.c +++ b/fs/exfat/fatent.c @@ -228,8 +228,7 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu) struct exfat_sb_info *sbi = EXFAT_SB(sb); struct buffer_head *bh; struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping; - sector_t blknr, last_blknr; - int i; + sector_t blknr, last_blknr, i; blknr = exfat_cluster_to_sector(sbi, clu); last_blknr = blknr + sbi->sect_per_clus;