exfat: fix divide-by-zero in exfat_allocate_bitmap
Subsystems (2)
Namjae Jeon
maintainerPATCH 1/1 exfat: fix divide-by-zero in exfat_allocate_bitmap
The variable max_ra_count can be 0 in exfat_allocate_bitmap(), which causes a divide-by-zero error in the subsequent modulo operation (i % max_ra_count), leading to a system crash.
When max_ra_count is 0, it means that readahead is not used. This patch load the bitmap without readahead.
Reported-by Jiaming Zhang <[email protected]>
Signed-off-by Namjae Jeon <[email protected]>
--- fs/exfat/balloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/exfat/balloc.c +1 -1
@@ -106,7 +106,7 @@ static int exfat_allocate_bitmap(struct super_block *sb, (PAGE_SHIFT - sb->s_blocksize_bits);for (i =0 ; i < sbi->map_sectors; i++) {/* Trigger the next readahead in advance. */ -if (0 == (i % max_ra_count)) { +if (max_ra_count &&0 == (i % max_ra_count)) {blk_start_plug (&plug);for (j = i; j <min (max_ra_count, sbi->map_sectors - i) + i; j++)sb_breadahead (sb, sector + j);
Signature · 1 line
2.25.1