ectool: Don't ignore fgets return code

Change-Id: I12dc449e06dee31b4b0811ab23c6e8635cf31512
Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/46667
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
diff --git a/util/ectool/ec.c b/util/ectool/ec.c
index f30d12f..a189a09 100644
--- a/util/ectool/ec.c
+++ b/util/ectool/ec.c
@@ -167,7 +167,10 @@
 		return -1;
 
 	while (!feof(fp) && (data == 0 || cmd == 0)) {
-		fgets(line, sizeof(line), fp);
+		if (fgets(line, sizeof(line), fp) == NULL) {
+			fprintf(stderr, "Can not read from /proc/ioports.\n");
+			break;
+		}
 		if (strstr(line, "EC data") != NULL)
 			data = strtol(line, NULL, 16);