Lawrence Livermore National Labs recently ran the source code analysis tool Coverity over the e2fsprogs-1.39 source to see if it would identify any significant bugs. The analysis turned up 38 mostly minor issues which are enumerated here with patches. We went through and resolved these issues but would love to see these mostly minor changes reviewed and commited upstream. Thanks, Brian Behlendorf <behlendorf1@xxxxxxxx>, and Herb Wartens <wartens2@xxxxxxxx> ----------------------------------------------------------------------------- Coverity ID: 41: Resource Leak Went through call paths pretty carefully. Looks like it is safe to free block_buf on an early return. The call paths that I found to use block_buf all seem to be done with block_buf after they complete. One example is calling swap_inode_blocks() which gets all the way to ext2fs_block_iterate2(). This function uses block_buf to set ctx_ind_buf, but is done with it once the function is complete. Index: e2fsprogs+chaos/e2fsck/swapfs.c =================================================================== --- e2fsprogs+chaos.orig/e2fsck/swapfs.c +++ e2fsprogs+chaos/e2fsck/swapfs.c @@ -113,7 +113,7 @@ static void swap_inodes(e2fsck_t ctx) dgrp_t group; unsigned int i; ext2_ino_t ino = 1; - char *buf, *block_buf; + char *buf, *block_buf = NULL; errcode_t retval; struct ext2_inode * inode; @@ -138,6 +138,8 @@ static void swap_inodes(e2fsck_t ctx) _("while reading inode table (group %d)"), group); ctx->flags |= E2F_FLAG_ABORT; + if (block_buf) + free(block_buf); return; } inode = (struct ext2_inode *) buf; @@ -162,11 +164,14 @@ static void swap_inodes(e2fsck_t ctx) ext2fs_inode_has_valid_blocks(inode))) swap_inode_blocks(ctx, ino, block_buf, inode); - if (ctx->flags & E2F_FLAG_SIGNAL_MASK) + if (ctx->flags & E2F_FLAG_SIGNAL_MASK) { + if (block_buf) + free(block_buf); return; + } if (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE) - ext2fs_swap_inode(fs, inode, inode, 1); + ext2fs_swap_inode(fs, inode,inode, 1); } retval = io_channel_write_blk(fs->io, fs->group_desc[group].bg_inode_table, @@ -176,6 +181,8 @@ static void swap_inodes(e2fsck_t ctx) _("while writing inode table (group %d)"), group); ctx->flags |= E2F_FLAG_ABORT; + if (block_buf) + free(block_buf); return; } } - To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html