[U-Boot] [PATCH 12/14] mkimage: Ensure file is closed in fdt_property_file()

Simon Glass sjg at chromium.org
Wed Mar 16 14:45:42 CET 2016


The file that is opened is not closed in all cases. Fix it.

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

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

diff --git a/tools/fit_image.c b/tools/fit_image.c
index 9d553d1..6e5c143 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -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:
-- 
2.7.0.rc3.207.g0ac5344



More information about the U-Boot mailing list