From: Jiaming Zhang <r772577952@gmail.com>
To: linkinjeon@kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
r772577952@gmail.com, sj1557.seo@samsung.com,
syzkaller@googlegroups.com, yuezhang.mo@sony.com
Subject: [PATCH 1/1] exfat: fix divide error in exfat_allocate_bitmap()
Date: Tue, 18 Nov 2025 15:33:38 +0800 [thread overview]
Message-ID: <20251118073338.576334-2-r772577952@gmail.com> (raw)
In-Reply-To: <20251118073338.576334-1-r772577952@gmail.com>
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@kernel.org>
Signed-off-by: Jiaming Zhang <r772577952@gmail.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
prev parent reply other threads:[~2025-11-18 7:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 6:54 [Linux Kernel Bug] divide error in exfat_load_bitmap Jiaming Zhang
2025-11-17 8:18 ` Namjae Jeon
2025-11-18 7:33 ` [PATCH 0/1] exfat: fix divide error in exfat_allocate_bitmap() Jiaming Zhang
2025-11-18 7:33 ` Jiaming Zhang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251118073338.576334-2-r772577952@gmail.com \
--to=r772577952@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sj1557.seo@samsung.com \
--cc=syzkaller@googlegroups.com \
--cc=yuezhang.mo@sony.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).