From: Simon Glass Date: Wed, 16 Mar 2016 13:45:42 +0000 (-0600) Subject: mkimage: Ensure file is closed in fdt_property_file() X-Git-Url: http://git.dujemihanovic.xyz/%22http:/www.sics.se/static/git-logo.png?a=commitdiff_plain;h=3bd3a54ac515c26c6f0abd001d74fac2c86a7e1d;p=u-boot.git mkimage: Ensure file is closed in fdt_property_file() The file that is opened is not closed in all cases. Fix it. Reported-by: Coverity (CID: 138490) Signed-off-by: Simon Glass Reviewed-by: Tom Rini --- diff --git a/tools/fit_image.c b/tools/fit_image.c index 9d553d10fb..6e5c143803 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: