Skip to content
Snippets Groups Projects
Commit b97d71e2 authored by Simon Glass's avatar Simon Glass Committed by Tom Rini
Browse files

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: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarTom Rini <trini@konsulko.com>
parent 6e0ffce6
Branches
Tags
No related merge requests found
...@@ -385,7 +385,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) ...@@ -385,7 +385,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
buf = malloc(fit_size); buf = malloc(fit_size);
if (!buf) { if (!buf) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err_munmap;
} }
buf_ptr = 0; buf_ptr = 0;
...@@ -393,7 +393,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) ...@@ -393,7 +393,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
if (images < 0) { if (images < 0) {
debug("%s: Cannot find /images node: %d\n", __func__, images); debug("%s: Cannot find /images node: %d\n", __func__, images);
ret = -EINVAL; ret = -EINVAL;
goto err; goto err_munmap;
} }
for (node = fdt_first_subnode(fdt, images); for (node = fdt_first_subnode(fdt, images);
...@@ -411,7 +411,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) ...@@ -411,7 +411,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
ret = fdt_delprop(fdt, node, "data"); ret = fdt_delprop(fdt, node, "data");
if (ret) { if (ret) {
ret = -EPERM; ret = -EPERM;
goto err; goto err_munmap;
} }
fdt_setprop_u32(fdt, node, "data-offset", buf_ptr); fdt_setprop_u32(fdt, node, "data-offset", buf_ptr);
fdt_setprop_u32(fdt, node, "data-size", len); 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) ...@@ -446,8 +446,11 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
ret = -EIO; ret = -EIO;
goto err; goto err;
} }
ret = 0; close(fd);
return 0;
err_munmap:
munmap(fdt, sbuf.st_size);
err: err:
close(fd); close(fd);
return ret; return ret;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment