[PATCH 05/19] libext2fs: always use ext2fs_mmp_get_mem to allocate fs->mmp_buf

Darrick J. Wong
2025-11-06T22:32:25Z

Always use our special allocator function to allocate the MMP buffer.
This will be useful in case we ever pass that buffer to ext2fs_mmp_write
on a filesystem that is opened with O_DIRECT.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
e2fsck/unix.c | 2 +-
lib/ext2fs/dupfs.c | 2 +-
lib/ext2fs/mmp.c | 6 +++---
misc/dumpe2fs.c | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 7768f0ed7c4e3e..335ca37763e65f 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -1230,7 +1230,7 @@ static errcode_t e2fsck_check_mmp(ext2_filsys fs, e2fsck_t ctx)

clear_problem_context(&pctx);
if (fs->mmp_buf == NULL) {
- retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
+ retval = ext2fs_mmp_get_mem(fs, &fs->mmp_buf);
if (retval)
goto check_error;
}
diff --git a/lib/ext2fs/dupfs.c b/lib/ext2fs/dupfs.c
index 0fd4e6c67afb5d..db3a812d8d1c0d 100644
--- a/lib/ext2fs/dupfs.c
+++ b/lib/ext2fs/dupfs.c
@@ -91,7 +91,7 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest)
goto errout;
}
if (src->mmp_buf) {
- retval = ext2fs_get_mem(src->blocksize, &fs->mmp_buf);
+ retval = ext2fs_mmp_get_mem(src, &fs->mmp_buf);
if (retval)
goto errout;
memcpy(fs->mmp_buf, src->mmp_buf, src->blocksize);
diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
index 41ef4e3e2aa6c5..e2823732e2b6a2 100644
--- a/lib/ext2fs/mmp.c
+++ b/lib/ext2fs/mmp.c
@@ -204,7 +204,7 @@ static errcode_t ext2fs_mmp_reset(ext2_filsys fs)
errcode_t retval = 0;

if (fs->mmp_buf == NULL) {
- retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
+ retval = ext2fs_mmp_get_mem(fs, &fs->mmp_buf);
if (retval)
goto out;
}
@@ -268,7 +268,7 @@ errcode_t ext2fs_mmp_init(ext2_filsys fs)
return EXT2_ET_INVALID_ARGUMENT;

if (fs->mmp_buf == NULL) {
- retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
+ retval = ext2fs_mmp_get_mem(fs, &fs->mmp_buf);
if (retval)
goto out;
}
@@ -306,7 +306,7 @@ errcode_t ext2fs_mmp_start(ext2_filsys fs)
errcode_t retval = 0;

if (fs->mmp_buf == NULL) {
- retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
+ retval = ext2fs_mmp_get_mem(fs, &fs->mmp_buf);
if (retval)
goto mmp_error;
}
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index b56d15d98caa47..1754fd4a999b9f 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -472,7 +472,7 @@ static void print_mmp_block(ext2_filsys fs)
errcode_t retval;

if (fs->mmp_buf == NULL) {
- retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
+ retval = ext2fs_mmp_get_mem(fs, &fs->mmp_buf);
if (retval) {
com_err(program_name, retval,
_("failed to alloc MMP buffer\n"));