[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <175182663005.1984706.2711154041137486922.stgit@frogsfrogsfrogs>
Date: Sun, 06 Jul 2025 11:31:16 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org, linux-ext4@...r.kernel.org
Subject: [PATCH 2/8] libext2fs: fix arguments passed to
->block_alloc_stats_range
From: Darrick J. Wong <djwong@...nel.org>
In ext2fs_block_alloc_stats_range, we use @num as the loop counter but
then pass it to the callback and @blk as the loop cursor. This means
that the range passed to e2fsck_block_alloc_stats_range starts beyond
the range that was actually freed and has a length of zero, which is not
at all correct.
Fix this by saving the original values and passing those instead.
Cc: <linux-ext4@...r.kernel.org> # v1.43
Fixes: 647e8786156061 ("libext2fs: add new hooks to support large allocations")
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
lib/ext2fs/alloc_stats.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/ext2fs/alloc_stats.c b/lib/ext2fs/alloc_stats.c
index 6f98bcc7cbd5f3..95a6438f252e0f 100644
--- a/lib/ext2fs/alloc_stats.c
+++ b/lib/ext2fs/alloc_stats.c
@@ -110,6 +110,9 @@ void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs,
void ext2fs_block_alloc_stats_range(ext2_filsys fs, blk64_t blk,
blk_t num, int inuse)
{
+ const blk64_t orig_blk = blk;
+ const blk_t orig_num = num;
+
#ifndef OMIT_COM_ERR
if (blk + num > ext2fs_blocks_count(fs->super)) {
com_err("ext2fs_block_alloc_stats_range", 0,
@@ -147,7 +150,7 @@ void ext2fs_block_alloc_stats_range(ext2_filsys fs, blk64_t blk,
ext2fs_mark_super_dirty(fs);
ext2fs_mark_bb_dirty(fs);
if (fs->block_alloc_stats_range)
- (fs->block_alloc_stats_range)(fs, blk, num, inuse);
+ (fs->block_alloc_stats_range)(fs, orig_blk, orig_num, inuse);
}
void ext2fs_set_block_alloc_stats_range_callback(ext2_filsys fs,
Powered by blists - more mailing lists