]> git.sur5r.net Git - u-boot/commitdiff
mkimage: Don't close the file if it wasn't opened
authorSimon Glass <sjg@chromium.org>
Wed, 16 Mar 2016 13:45:43 +0000 (07:45 -0600)
committerTom Rini <trini@konsulko.com>
Tue, 22 Mar 2016 16:16:28 +0000 (12:16 -0400)
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>
tools/fit_image.c

index 6e5c143803c627c4f92de28e4d79e61363bfee27..ddefa72f3479ffacf746d9b5d46a3b017b92937a 100644 (file)
@@ -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",