From: Brian Behlendorf Date: Wed, 21 Mar 2007 21:53:33 +0000 (-0400) Subject: [COVERITY] Fix (error case) memory leak in debugfs X-Git-Tag: E2FSPROGS-1_40~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89456558df36b22ca664ead88e768d6a486c7cef;p=thirdparty%2Fe2fsprogs.git [COVERITY] Fix (error case) memory leak in debugfs Handle leaked cbuf due to early returns with a generic failure path. Coverity ID: 24: Resource Leak Signed-off-by: Brian Behlendorf Signed-off-by: "Theodore Ts'o" --- diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog index ae7d09b14..3a189af3b 100644 --- a/debugfs/ChangeLog +++ b/debugfs/ChangeLog @@ -1,5 +1,7 @@ 2007-03-21 Theodore Tso + * htree.c (htree_dump_int_block): Fix memory leak on error paths. + * dump.c (rdump_dirent), htree.c (htree_dump_leaf_node), ls.c (list_dir_proc): Add an extra byte to EXT2_NAME_LEN to avoid the possibility of an array overrun if the diff --git a/debugfs/htree.c b/debugfs/htree.c index 2d51ec3ab..bd1fd5128 100644 --- a/debugfs/htree.c +++ b/debugfs/htree.c @@ -161,19 +161,20 @@ static void htree_dump_int_block(ext2_filsys fs, ext2_ino_t ino, if (errcode) { com_err("htree_dump_int_block", errcode, "while mapping logical block %u\n", blk); - return; + goto errout; } errcode = io_channel_read_blk(current_fs->io, pblk, 1, buf); if (errcode) { com_err("htree_dump_int_block", errcode, "while reading block %u\n", blk); - return; + goto errout; } htree_dump_int_node(fs, ino, inode, rootnode, (struct ext2_dx_entry *) (buf+8), cbuf, level); +errout: free(cbuf); }