summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-03-16 07:45:41 -0600
committerTom Rini <trini@konsulko.com>2016-03-22 12:16:27 -0400
commit7b0bbd886d553c3cffc5b3eb29256b05856076ee (patch)
treecbb61667065e1334f484d75510b30b16d0fb6b46 /tools
parent21c2975a9421c55938274a542976bc8d3746c1e3 (diff)
downloadu-boot-imx-7b0bbd886d553c3cffc5b3eb29256b05856076ee.zip
u-boot-imx-7b0bbd886d553c3cffc5b3eb29256b05856076ee.tar.gz
u-boot-imx-7b0bbd886d553c3cffc5b3eb29256b05856076ee.tar.bz2
mkimage: Fix missing free() and close() in fit_build()
Make sure that both the error path and normal return free the buffer and close the file. Reported-by: Coverity (CID: 138491) Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/fit_image.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/fit_image.c b/tools/fit_image.c
index e628212..9d553d1 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -329,7 +329,7 @@ static int fit_build(struct image_tool_params *params, const char *fname)
if (ret < 0) {
fprintf(stderr, "%s: Failed to build FIT image\n",
params->cmdname);
- goto err;
+ goto err_buf;
}
size = ret;
fd = open(fname, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0666);
@@ -346,9 +346,12 @@ static int fit_build(struct image_tool_params *params, const char *fname)
goto err;
}
close(fd);
+ free(buf);
return 0;
err:
+ close(fd);
+err_buf:
free(buf);
return -1;
}