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>
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);
goto err;
}
close(fd);
+ free(buf);
return 0;
err:
+ close(fd);
+err_buf:
free(buf);
return -1;
}