aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2021-02-14 23:51:45 -0500
committerTheodore Ts'o <tytso@mit.edu>2021-02-14 23:51:45 -0500
commit71f9bf7b08f2f7b632323719a4e69e94e0567a70 (patch)
tree041dc80fbbfce26b066de2a21570c99cba074033
parente3a13a47e6f215c5db5cb58f646b422d6330fc6a (diff)
downloade2fsprogs-71f9bf7b08f2f7b632323719a4e69e94e0567a70.tar.gz
libext2fs: fix crash when ext2fs_mmp_stop() is called before MMP is initialized
The fatal_error() function in e2fsck can call ext2fs_mmp_stop() on a file system where MMP hasn't yet been initialized. When that happens, instead of crashing, have ext2fs_mmp_stop() return success, since mmp doesn't need to be stopped if it hasn't even been initialized yet. Addresses-Debian-Bug: #696609 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--lib/ext2fs/mmp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
index c21ae272f..023dccf4d 100644
--- a/lib/ext2fs/mmp.c
+++ b/lib/ext2fs/mmp.c
@@ -403,7 +403,8 @@ errcode_t ext2fs_mmp_stop(ext2_filsys fs)
errcode_t retval = 0;
if (!ext2fs_has_feature_mmp(fs->super) ||
- !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP))
+ !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP) ||
+ (fs->mmp_buf == NULL) || (fs->mmp_cmp == NULL))
goto mmp_error;
retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);