Skip to content

Commit 993bf0f

Browse files
LiBaokun96tytso
authored andcommitted
ext4: avoid dividing by 0 in mb_update_avg_fragment_size() when block bitmap corrupt
Determine if bb_fragments is 0 instead of determining bb_free to eliminate the risk of dividing by zero when the block bitmap is corrupted. Signed-off-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20240104142040.2835097-6-libaokun1@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 2331fd4 commit 993bf0f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ext4/mballoc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ mb_update_avg_fragment_size(struct super_block *sb, struct ext4_group_info *grp)
842842
struct ext4_sb_info *sbi = EXT4_SB(sb);
843843
int new_order;
844844

845-
if (!test_opt2(sb, MB_OPTIMIZE_SCAN) || grp->bb_free == 0)
845+
if (!test_opt2(sb, MB_OPTIMIZE_SCAN) || grp->bb_fragments == 0)
846846
return;
847847

848848
new_order = mb_avg_fragment_size_order(sb,

0 commit comments

Comments
 (0)