summaryrefslogtreecommitdiff
path: root/util/amdfwtool
diff options
context:
space:
mode:
authorRichard Spiegel <richard.spiegel@silverbackltd.com>2018-02-20 14:20:15 -0700
committerPatrick Georgi <pgeorgi@google.com>2018-02-22 09:59:40 +0000
commit7b89a28149b5de9228342144d48673e0b0d2728a (patch)
tree4191139aebd7897cd8bd240357e1bd954819268c /util/amdfwtool
parent51605e2c9e21d0aa81a8368ef818b48cd34f3bfd (diff)
downloadcoreboot-7b89a28149b5de9228342144d48673e0b0d2728a.tar.xz
util/amdfwtool/amdfwtool.c: Check fstat return
Funtion fstat will return -1 if there's any error, 0 if successful. Check that fstat return is equal to 0, print error message and exit if not 0. This fixes CIDs 1353018 and 1353020 BUG=b:72062481 TEST=Build no errors Change-Id: I83284d9125c75a29471f213f88b9181d5edba2e6 Signed-off-by: Richard Spiegel <richard.spiegel@silverbackltd.com> Reviewed-on: https://review.coreboot.org/23827 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util/amdfwtool')
-rw-r--r--util/amdfwtool/amdfwtool.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c
index 303a31df3f..406ae0560b 100644
--- a/util/amdfwtool/amdfwtool.c
+++ b/util/amdfwtool/amdfwtool.c
@@ -298,7 +298,11 @@ static uint32_t integrate_firmwares(char *base, uint32_t pos, uint32_t *romsig,
free(base);
exit(1);
}
- fstat(fd, &fd_stat);
+ if (fstat(fd, &fd_stat)) {
+ printf("fstat error: %s\n", strerror(errno));
+ free(base);
+ exit(1);
+ }
switch (fw_table[i].type) {
case AMD_FW_IMC:
@@ -369,7 +373,11 @@ static uint32_t integrate_psp_firmwares(char *base, uint32_t pos,
free(base);
exit(1);
}
- fstat(fd, &fd_stat);
+ if (fstat(fd, &fd_stat)) {
+ printf("fstat error: %s\n", strerror(errno));
+ free(base);
+ exit(1);
+ }
pspdir[4+4*i+1] = (uint32_t)fd_stat.st_size;
pspdir[4+4*i+2] = pos + rom_base_address;