[coreboot-gerrit] Change in coreboot[master]: util/amdfwtool/amdfwtool.c: Check fstat return

Richard Spiegel (Code Review) gerrit at coreboot.org
Tue Feb 20 22:20:29 CET 2018


Richard Spiegel has uploaded this change for review. ( https://review.coreboot.org/23827


Change subject: util/amdfwtool/amdfwtool.c: Check fstat return
......................................................................

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 at silverbackltd.com>
---
M util/amdfwtool/amdfwtool.c
1 file changed, 10 insertions(+), 2 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/27/23827/1

diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c
index 303a31d..406ae05 100644
--- a/util/amdfwtool/amdfwtool.c
+++ b/util/amdfwtool/amdfwtool.c
@@ -298,7 +298,11 @@
 				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 @@
 				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;

-- 
To view, visit https://review.coreboot.org/23827
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I83284d9125c75a29471f213f88b9181d5edba2e6
Gerrit-Change-Number: 23827
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Spiegel <richard.spiegel at silverbackltd.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180220/462d963f/attachment.html>


More information about the coreboot-gerrit mailing list