[coreboot-gerrit] Patch set updated for coreboot: a96170b cbfstool: cbfs-mkstage.c: Free `buffer` on error path

Paul Menzel (paulepanter@users.sourceforge.net) gerrit at coreboot.org
Fri Apr 12 12:31:06 CEST 2013

Paul Menzel (paulepanter at users.sourceforge.net) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3069


commit a96170b8e41367e8f269780396bdab9ae698b88b
Author: Paul Menzel <paulepanter at users.sourceforge.net>
Date:   Thu Apr 11 10:45:11 2013 +0200

    cbfstool: cbfs-mkstage.c: Free `buffer` on error path
    Cppcheck warns about a memory leak, present since adding romtool,
    which was renamed to cbfstool, in commit 5d01ec0f.
        $ cppcheck --version
        Cppcheck 1.59
        [cbfs-mkstage.c:170]: (error) Memory leak: buffer
    Indeed the memory pointed to by `buffer` is not freed on the error path,
    so add `free(buffer)` to fix this.
    Change-Id: I6cbf82479027747c800c5fe847f20b779e261ef4
    Signed-off-by: Paul Menzel <paulepanter at users.sourceforge.net>
 util/cbfstool/cbfs-mkstage.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/util/cbfstool/cbfs-mkstage.c b/util/cbfstool/cbfs-mkstage.c
index 4008367..dfc93c2 100644
--- a/util/cbfstool/cbfs-mkstage.c
+++ b/util/cbfstool/cbfs-mkstage.c
@@ -167,6 +167,7 @@ int parse_elf_to_stage(const struct buffer *input, struct buffer *output,
 	if (buffer_create(output, sizeof(*stage) + data_end - data_start,
 			  input->name) != 0) {
 		ERROR("Unable to allocate memory: %m\n");
+		free(buffer);
 		return -1;
 	memset(output->data, 0, output->size);

More information about the coreboot-gerrit mailing list