diff mbox

[U-Boot,13/14] mkimage: Don't close the file if it wasn't opened

Message ID 1458135945-13385-14-git-send-email-sjg@chromium.org
State Accepted
Commit 5b15a2596f7852177c7f451349b353e6e52742a2
Delegated to: Tom Rini
Headers show

Commit Message

Simon Glass March 16, 2016, 1:45 p.m. UTC
The error path for fit_import_data() is incorrect if the second open() call
fails.

Reported-by: Coverity (CID: 138489)
Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/fit_image.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Tom Rini March 17, 2016, 2:09 a.m. UTC | #1
On Wed, Mar 16, 2016 at 07:45:43AM -0600, Simon Glass wrote:

> The error path for fit_import_data() is incorrect if the second open() call
> fails.
> 
> Reported-by: Coverity (CID: 138489)
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>
Tom Rini March 23, 2016, 2 a.m. UTC | #2
On Wed, Mar 16, 2016 at 07:45:43AM -0600, Simon Glass wrote:

> The error path for fit_import_data() is incorrect if the second open() call
> fails.
> 
> Reported-by: Coverity (CID: 138489)
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/tools/fit_image.c b/tools/fit_image.c
index 6e5c143..ddefa72 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -537,8 +537,8 @@  static int fit_import_data(struct image_tool_params *params, const char *fname)
 	if (fd < 0) {
 		fprintf(stderr, "%s: Can't open %s: %s\n",
 			params->cmdname, fname, strerror(errno));
-		ret = -EIO;
-		goto err;
+		free(fdt);
+		return -EIO;
 	}
 	if (write(fd, fdt, new_size) != new_size) {
 		debug("%s: Failed to write external data to file %s\n",