summaryrefslogtreecommitdiff
path: root/util/cbfstool
diff options
context:
space:
mode:
authorPaul Menzel <paulepanter@users.sourceforge.net>2013-04-11 10:45:11 +0200
committerStefan Reinauer <stefan.reinauer@coreboot.org>2013-04-12 20:22:39 +0200
commit2c8f81b57b20c14edf4b77d3f5dcd2bcce717180 (patch)
tree5b07d395f28b95bbd23535a0ea6381383880fbc9 /util/cbfstool
parente76d8d7ced79d618291f6f0b1331d60a86855f2e (diff)
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@users.sourceforge.net> Reviewed-on: http://review.coreboot.org/3069 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util/cbfstool')
-rw-r--r--util/cbfstool/cbfs-mkstage.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/util/cbfstool/cbfs-mkstage.c b/util/cbfstool/cbfs-mkstage.c
index 4008367d9d..dfc93c20e9 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);