summaryrefslogtreecommitdiff
path: root/e2fsck
diff options
context:
space:
mode:
authorBrian Behlendorf <behlendorf1@llnl.gov>2007-03-29 00:19:17 -0400
committerTheodore Ts'o <tytso@mit.edu>2007-03-29 00:19:17 -0400
commit2bfe0bdba37bfd0e4378e855377ebaa823846ea3 (patch)
treef0b925b15ec28d2b6a84417df3299ae4cd4c0019 /e2fsck
parent06c9c6ffc16cbf4c9513ddea3c73328f2a937eb7 (diff)
downloade2fsprogs-2bfe0bdba37bfd0e4378e855377ebaa823846ea3.tar.gz
[COVERITY] Fix (error case only) memory leak in e2fsck_get_journal
Coverity ID: 43: Resource Leak Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Diffstat (limited to 'e2fsck')
-rw-r--r--e2fsck/ChangeLog1
-rw-r--r--e2fsck/journal.c30
2 files changed, 17 insertions, 14 deletions
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index 4c97cd32..93bb5f54 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -3,6 +3,7 @@
* pass1.c (e2fsck_pass1, check_ext_attr),
pass5.c (check_block_bitmaps, check_inode_bitmaps),
pass4.c (e2fsck_pass4), swapfs.c (swap_inodes),
+ journal.c (e2fsck_get_journal),
unix.c (parse_extended_opts): Fix memory leaks
2007-03-21 Theodore Tso <tytso@mit.edu>
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 34a73828..f1e3ad02 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -206,9 +206,9 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
int ext_journal = 0;
int tried_backup_jnl = 0;
int i;
-
+
clear_problem_context(&pctx);
-
+
journal = e2fsck_allocate_memory(ctx, sizeof(journal_t), "journal");
if (!journal) {
return EXT2_ET_NO_MEMORY;
@@ -220,19 +220,21 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
goto errout;
}
dev_journal = dev_fs+1;
-
+
dev_fs->k_ctx = dev_journal->k_ctx = ctx;
dev_fs->k_dev = K_DEV_FS;
dev_journal->k_dev = K_DEV_JOURNAL;
-
+
journal->j_dev = dev_journal;
journal->j_fs_dev = dev_fs;
journal->j_inode = NULL;
journal->j_blocksize = ctx->fs->blocksize;
if (uuid_is_null(sb->s_journal_uuid)) {
- if (!sb->s_journal_inum)
- return EXT2_ET_BAD_INODE_NUM;
+ if (!sb->s_journal_inum) {
+ retval = EXT2_ET_BAD_INODE_NUM;
+ goto errout;
+ }
j_inode = e2fsck_allocate_memory(ctx, sizeof(*j_inode),
"journal inode");
if (!j_inode) {
@@ -242,7 +244,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
j_inode->i_ctx = ctx;
j_inode->i_ino = sb->s_journal_inum;
-
+
if ((retval = ext2fs_read_inode(ctx->fs,
sb->s_journal_inum,
&j_inode->i_ext2))) {
@@ -311,12 +313,13 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
ctx->journal_name = blkid_devno_to_devname(sb->s_journal_dev);
}
journal_name = ctx->journal_name;
-
+
if (!journal_name) {
fix_problem(ctx, PR_0_CANT_FIND_JOURNAL, &pctx);
- return EXT2_ET_LOAD_EXT_JOURNAL;
+ retval = EXT2_ET_LOAD_EXT_JOURNAL;
+ goto errout;
}
-
+
jfs_debug(1, "Using journal file %s\n", journal_name);
io_ptr = unix_io_manager;
}
@@ -368,7 +371,7 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
retval = EXT2_ET_LOAD_EXT_JOURNAL;
goto errout;
}
-
+
journal->j_maxlen = jsuper.s_blocks_count;
start++;
}
@@ -377,10 +380,10 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
retval = EXT2_ET_NO_MEMORY;
goto errout;
}
-
+
journal->j_sb_buffer = bh;
journal->j_superblock = (journal_superblock_t *)bh->b_data;
-
+
#ifdef USE_INODE_IO
if (j_inode)
ext2fs_free_mem(&j_inode);
@@ -397,7 +400,6 @@ errout:
if (journal)
ext2fs_free_mem(&journal);
return retval;
-
}
static errcode_t e2fsck_journal_fix_bad_inode(e2fsck_t ctx,