[COVERITY] Fix (error case) memory leak in libext2fs (ext2fs_write_inode_full)

Need to free w_inode on early exit if w_inode != &temp_inode.

Coverity ID: 22: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
bitmap-optimize
Brian Behlendorf 2007-03-21 17:38:47 -04:00 committed by Theodore Ts'o
parent f19c46dfbc
commit e649be9daa
2 changed files with 9 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2007-03-21 Theodore Tso <tytso@mit.edu>
* inode.c (ext2fs_write_inode_full): Fix memory leak on error
return (when the inode table is missing).
2006-11-30 Theodore Tso <tytso@mit.edu>
* ext2_fs.h (struct ext4_group_desc): Fix missing bg_pad which

View File

@ -669,8 +669,10 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) *
EXT2_INODE_SIZE(fs->super);
block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super);
if (!fs->group_desc[(unsigned) group].bg_inode_table)
return EXT2_ET_MISSING_INODE_TABLE;
if (!fs->group_desc[(unsigned) group].bg_inode_table) {
retval = EXT2_ET_MISSING_INODE_TABLE;
goto errout;
}
block_nr = fs->group_desc[(unsigned) group].bg_inode_table + block;
offset &= (EXT2_BLOCK_SIZE(fs->super) - 1);