|
@@ -3195,10 +3195,15 @@ static int count_overhead(struct super_block *sb, ext4_group_t grp,
|
|
|
ext4_set_bit(s++, buf);
|
|
|
count++;
|
|
|
}
|
|
|
- for (j = ext4_bg_num_gdb(sb, grp); j > 0; j--) {
|
|
|
- ext4_set_bit(EXT4_B2C(sbi, s++), buf);
|
|
|
- count++;
|
|
|
+ j = ext4_bg_num_gdb(sb, grp);
|
|
|
+ if (s + j > EXT4_BLOCKS_PER_GROUP(sb)) {
|
|
|
+ ext4_error(sb, "Invalid number of block group "
|
|
|
+ "descriptor blocks: %d", j);
|
|
|
+ j = EXT4_BLOCKS_PER_GROUP(sb) - s;
|
|
|
}
|
|
|
+ count += j;
|
|
|
+ for (; j > 0; j--)
|
|
|
+ ext4_set_bit(EXT4_B2C(sbi, s++), buf);
|
|
|
}
|
|
|
if (!count)
|
|
|
return 0;
|