]> git.sur5r.net Git - u-boot/commitdiff
mkimage: Ensure file is closed in fdt_property_file()
authorSimon Glass <sjg@chromium.org>
Wed, 16 Mar 2016 13:45:42 +0000 (07:45 -0600)
committerTom Rini <trini@konsulko.com>
Tue, 22 Mar 2016 16:16:27 +0000 (12:16 -0400)
The file that is opened is not closed in all cases. Fix it.

Reported-by: Coverity (CID: 138490)
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
tools/fit_image.c

index 9d553d10fb8e72e41eb46d05bcb9466db8a731e3..6e5c143803c627c4f92de28e4d79e61363bfee27 100644 (file)
@@ -123,13 +123,14 @@ static int fdt_property_file(struct image_tool_params *params,
 
        ret = fdt_property_placeholder(fdt, "data", sbuf.st_size, &ptr);
        if (ret)
-               return ret;
+               goto err;
        ret = read(fd, ptr, sbuf.st_size);
        if (ret != sbuf.st_size) {
                fprintf(stderr, "%s: Can't read %s: %s\n",
                        params->cmdname, fname, strerror(errno));
                goto err;
        }
+       close(fd);
 
        return 0;
 err: