Skip to content
Snippets Groups Projects
Commit ac71d410 authored by Michal Simek's avatar Michal Simek Committed by Tom Rini
Browse files

tools: mkimage: Call fclose in error path


This patch is fixing missing fclose() calls
in error patch introduced by:
"tools: mkimage: Use fstat instead of stat to avoid malicious hacks"
(sha1: ebe0f53f)

Reported-by: Coverity (CID: 155064, 155065)
Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
parent d0cf5512
No related branches found
No related tags found
No related merge requests found
......@@ -239,11 +239,15 @@ static void zynqimage_parse_initparams(struct zynq_header *zynqhdr,
}
err = fstat(fileno(fp), &path_stat);
if (err)
if (err) {
fclose(fp);
return;
}
if (!S_ISREG(path_stat.st_mode))
if (!S_ISREG(path_stat.st_mode)) {
fclose(fp);
return;
}
do {
r = fscanf(fp, "%x %x", &reginit.address, &reginit.data);
......
......@@ -251,11 +251,15 @@ static void zynqmpimage_parse_initparams(struct zynqmp_header *zynqhdr,
}
err = fstat(fileno(fp), &path_stat);
if (err)
if (err) {
fclose(fp);
return;
}
if (!S_ISREG(path_stat.st_mode))
if (!S_ISREG(path_stat.st_mode)) {
fclose(fp);
return;
}
do {
r = fscanf(fp, "%x %x", &reginit.address, &reginit.data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment