summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-03-16 07:45:39 -0600
committerTom Rini <trini@konsulko.com>2016-03-22 12:16:20 -0400
commitb97d71e26a0c348d49e83eca9548d8cfe2da07ec (patch)
tree609931b1be076a13008e95055ab283528e98603d /tools
parent6e0ffce6cb50beb2fdf2cb0112cb359a7dede723 (diff)
downloadu-boot-imx-b97d71e26a0c348d49e83eca9548d8cfe2da07ec.zip
u-boot-imx-b97d71e26a0c348d49e83eca9548d8cfe2da07ec.tar.gz
u-boot-imx-b97d71e26a0c348d49e83eca9548d8cfe2da07ec.tar.bz2
mkimage: Fix error path in fit_extract_data()
The 'fdt' variable is not unmapped in all error cases. Fix this. Reported-by: Coverity (CID: 138493) 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.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 8d58370..bfb43b2 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -385,7 +385,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
buf = malloc(fit_size);
if (!buf) {
ret = -ENOMEM;
- goto err;
+ goto err_munmap;
}
buf_ptr = 0;
@@ -393,7 +393,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
if (images < 0) {
debug("%s: Cannot find /images node: %d\n", __func__, images);
ret = -EINVAL;
- goto err;
+ goto err_munmap;
}
for (node = fdt_first_subnode(fdt, images);
@@ -411,7 +411,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
ret = fdt_delprop(fdt, node, "data");
if (ret) {
ret = -EPERM;
- goto err;
+ goto err_munmap;
}
fdt_setprop_u32(fdt, node, "data-offset", buf_ptr);
fdt_setprop_u32(fdt, node, "data-size", len);
@@ -446,8 +446,11 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
ret = -EIO;
goto err;
}
- ret = 0;
+ close(fd);
+ return 0;
+err_munmap:
+ munmap(fdt, sbuf.st_size);
err:
close(fd);
return ret;