From f93625b292e69e03755fd63cf3fa6f2cce14a344 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 21 Mar 2007 17:43:37 -0400 Subject: [PATCH] [COVERITY] Fix (error case) memory leak in libext2fs (ext2fs_image_inode_write) Use pre-existing early exit label in function to handle proper error code return and local memory allocation cleanup. Coverity ID: 23: Resource Leak Signed-off-by: Brian Behlendorf --- lib/ext2fs/ChangeLog | 5 +++-- lib/ext2fs/imager.c | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index b0c0f7f8..7d55e9d9 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,7 +1,8 @@ 2007-03-21 Theodore Tso - * inode.c (ext2fs_write_inode_full): Fix memory leak on error - return (when the inode table is missing). + * imager.c (ext2fs_image_inode_write), inode.c + (ext2fs_write_inode_full): Fix memory leak on error return + (when the inode table is missing). 2006-11-30 Theodore Tso diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c index 596fbbeb..ac8309cf 100644 --- a/lib/ext2fs/imager.c +++ b/lib/ext2fs/imager.c @@ -72,8 +72,10 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags) for (group = 0; group < fs->group_desc_count; group++) { blk = fs->group_desc[(unsigned)group].bg_inode_table; - if (!blk) - return EXT2_ET_MISSING_INODE_TABLE; + if (!blk) { + retval = EXT2_ET_MISSING_INODE_TABLE; + goto errout; + } left = fs->inode_blocks_per_group; while (left) { c = BUF_BLOCKS; -- 2.11.0