[PATCH 1/1] tracefile_tracecmd: add null return from fgets when EOF occurs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a EOF check on fgets calls.

Signed-off-by: Colin Ian King <colin.i.king@xxxxxxxxx>
---
 tracefile_tracecmd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tracefile_tracecmd.c b/tracefile_tracecmd.c
index eda7b6b..9d38bc4 100644
--- a/tracefile_tracecmd.c
+++ b/tracefile_tracecmd.c
@@ -97,11 +97,12 @@ static struct cpuidle_datas * tracecmd_report_load(const char *filename)
 	/* Number of CPUs */
 	nrcpus = 0;
 	line = fgets(buffer, BUFSIZE, f);
+	if (!line)
+		goto error_close;
 	ret = sscanf(buffer, "cpus=%u", &nrcpus);
 	if (ret != 1)
 		nrcpus = 0;
 	line = fgets(buffer, BUFSIZE, f);
-
 	if (!line)
 		goto error_close;
 
-- 
2.38.1




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux