summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorHidehiro Kawai <hidehiro.kawai.ez@hitachi.com>2008-10-27 22:51:46 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-10-27 22:51:46 -0400
commit44d6f78756560e95903de239e10f8a40a6eae444 (patch)
tree2f4e1ec9219eb9f8e3d564856e5c40174bd869e7 /fs
parent0173a3265b228da319ceb9c1ec6a5682fd1b2d92 (diff)
downloadblackbird-op-linux-44d6f78756560e95903de239e10f8a40a6eae444.tar.gz
blackbird-op-linux-44d6f78756560e95903de239e10f8a40a6eae444.zip
ext3: fix a bug accessing freed memory in ext3_abort
Vegard Nossum reported a bug which accesses freed memory (found via kmemcheck). When journal has been aborted, ext3_put_super() calls ext3_abort() after freeing the journal_t object, and then ext3_abort() accesses it. This patch fix it. Signed-off-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com> Acked-by: Jan Kara <jack@suse.cz> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext3/super.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 18eaa78ecb4e..e5717a4fae67 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -281,7 +281,8 @@ void ext3_abort (struct super_block * sb, const char * function,
EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS;
sb->s_flags |= MS_RDONLY;
EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT;
- journal_abort(EXT3_SB(sb)->s_journal, -EIO);
+ if (EXT3_SB(sb)->s_journal)
+ journal_abort(EXT3_SB(sb)->s_journal, -EIO);
}
void ext3_warning (struct super_block * sb, const char * function,
@@ -390,11 +391,14 @@ static void ext3_put_super (struct super_block * sb)
{
struct ext3_sb_info *sbi = EXT3_SB(sb);
struct ext3_super_block *es = sbi->s_es;
- int i;
+ int i, err;
ext3_xattr_put_super(sb);
- if (journal_destroy(sbi->s_journal) < 0)
+ err = journal_destroy(sbi->s_journal);
+ sbi->s_journal = NULL;
+ if (err < 0)
ext3_abort(sb, __func__, "Couldn't clean up the journal");
+
if (!(sb->s_flags & MS_RDONLY)) {
EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
es->s_state = cpu_to_le16(sbi->s_mount_state);
OpenPOWER on IntegriCloud