[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20251118073338.576334-2-r772577952@gmail.com>
Date: Tue, 18 Nov 2025 15:33:38 +0800
From: Jiaming Zhang <r772577952@...il.com>
To: linkinjeon@...nel.org
Cc: linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
r772577952@...il.com,
sj1557.seo@...sung.com,
syzkaller@...glegroups.com,
yuezhang.mo@...y.com
Subject: [PATCH 1/1] exfat: fix divide error in exfat_allocate_bitmap()
The variable max_ra_count in exfat_allocate_bitmap() can be 0, leading
to a divide-by-zero error in the modulo operation (i % max_ra_count)
inside the loop. Avoid this by adding a check for max_ra_count before
performing the modulo operation.
Fixes: 9fd688678dd8
Closes: https://lore.kernel.org/lkml/CANypQFb0NeToJrTY5PQi57K_440xQJ1uUS2pMOKqLsqTdEGbRw@mail.gmail.com/
Suggested-by: Namjae Jeon <linkinjeon@...nel.org>
Signed-off-by: Jiaming Zhang <r772577952@...il.com>
---
fs/exfat/balloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/exfat/balloc.c b/fs/exfat/balloc.c
index 2d2d510f2372..0b6466b3490a 100644
--- a/fs/exfat/balloc.c
+++ b/fs/exfat/balloc.c
@@ -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);
--
2.34.1
Powered by blists - more mailing lists