The return value of fstat was not checked in kwbimage, and in the case
of an error, the already open file was not closed. Fix both errors.
Reported-by: Coverity (CID: 155971)
Reported-by: Coverity (CID: 155969)
Signed-off-by: Mario Six <mario.six@gdsys.cc>
Signed-off-by: Stefan Roese <sr@denx.de>
return -1;
}
- fstat(fileno(bin), &s);
+ if (fstat(fileno(bin), &s)) {
+ fprintf(stderr, "Cannot stat binary file %s\n",
+ binarye->binary.file);
+ goto err_close;
+ }
binhdrsz = sizeof(struct opt_hdr_v1) +
(binarye->binary.nargs + 2) * sizeof(uint32_t) +
fprintf(stderr,
"Could not read binary image %s\n",
binarye->binary.file);
- return -1;
+ goto err_close;
}
fclose(bin);
cur += sizeof(uint32_t);
return 0;
+
+err_close:
+ fclose(bin);
+
+ return -1;
}
#if defined(CONFIG_KWB_SECURE)