Commit 7b0bbd88 authored by Simon Glass's avatar Simon Glass Committed by Tom Rini

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: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarTom Rini <trini@konsulko.com>
parent 21c2975a
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment