Some error paths did not properly free "buf" And the normal exit seemed to close e2_file twice (?) Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx> --- misc/e2initrd_helper.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/misc/e2initrd_helper.c b/misc/e2initrd_helper.c index eaf9ce6..3d9f5ab 100644 --- a/misc/e2initrd_helper.c +++ b/misc/e2initrd_helper.c @@ -73,7 +73,7 @@ static errcode_t get_file(ext2_filsys fs, const char * filename, { errcode_t retval; char *buf; - ext2_file_t e2_file; + ext2_file_t e2_file = NULL; unsigned int got; struct ext2_inode inode; ext2_ino_t ino; @@ -101,7 +101,7 @@ static errcode_t get_file(ext2_filsys fs, const char * filename, retval = ext2fs_file_open(fs, ino, 0, &e2_file); if (retval) - return retval; + goto errout; retval = ext2fs_file_read(e2_file, buf, inode.i_size, &got); if (retval) @@ -109,13 +109,16 @@ static errcode_t get_file(ext2_filsys fs, const char * filename, retval = ext2fs_file_close(e2_file); if (retval) - return retval; + goto errout; ret_file->buf = buf; ret_file->size = (int) got; + return 0; errout: - ext2fs_file_close(e2_file); + free(buf); + if (e2_file) + ext2fs_file_close(e2_file); return retval; } -- 1.7.4.1 -- 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