From 3a7825983c506d5a521862bfa5700a87c525227d Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Thu, 22 Oct 2020 22:16:20 +0000 Subject: [PATCH] ectool: Don't ignore fgets return code Change-Id: I12dc449e06dee31b4b0811ab23c6e8635cf31512 Signed-off-by: Stefan Reinauer Reviewed-on: https://review.coreboot.org/c/coreboot/+/46667 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- util/ectool/ec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/ectool/ec.c b/util/ectool/ec.c index f30d12f976..a189a094b5 100644 --- a/util/ectool/ec.c +++ b/util/ectool/ec.c @@ -167,7 +167,10 @@ int get_ec_ports(void) 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);