Skip to content

Commit d70a580

Browse files
committed
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. Fixes: 9fd6886 ("exfat: optimize allocation bitmap loading time") Reported-by: Jiaming Zhang <r772577952@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent 866cba3 commit d70a580

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/exfat/balloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static int exfat_allocate_bitmap(struct super_block *sb,
106106
(PAGE_SHIFT - sb->s_blocksize_bits);
107107
for (i = 0; i < sbi->map_sectors; i++) {
108108
/* Trigger the next readahead in advance. */
109-
if (0 == (i % max_ra_count)) {
109+
if (max_ra_count && 0 == (i % max_ra_count)) {
110110
blk_start_plug(&plug);
111111
for (j = i; j < min(max_ra_count, sbi->map_sectors - i) + i; j++)
112112
sb_breadahead(sb, sector + j);

0 commit comments

Comments
 (0)