aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/power/x86/turbostat/turbostat.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 51741a1b7021..4f7b88b035c3 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -1189,7 +1189,10 @@ int cpu_is_first_sibling_in_core(int cpu)
1189 perror(path); 1189 perror(path);
1190 exit(1); 1190 exit(1);
1191 } 1191 }
1192 fscanf(filep, "%d", &first_cpu); 1192 if (fscanf(filep, "%d", &first_cpu) != 1) {
1193 perror(path);
1194 exit(1);
1195 }
1193 fclose(filep); 1196 fclose(filep);
1194 return (cpu == first_cpu); 1197 return (cpu == first_cpu);
1195} 1198}
@@ -1210,7 +1213,10 @@ int cpu_is_first_core_in_package(int cpu)
1210 perror(path); 1213 perror(path);
1211 exit(1); 1214 exit(1);
1212 } 1215 }
1213 fscanf(filep, "%d", &first_cpu); 1216 if (fscanf(filep, "%d", &first_cpu) != 1) {
1217 perror(path);
1218 exit(1);
1219 }
1214 fclose(filep); 1220 fclose(filep);
1215 return (cpu == first_cpu); 1221 return (cpu == first_cpu);
1216} 1222}
@@ -1227,7 +1233,10 @@ int get_physical_package_id(int cpu)
1227 perror(path); 1233 perror(path);
1228 exit(1); 1234 exit(1);
1229 } 1235 }
1230 fscanf(filep, "%d", &pkg); 1236 if (fscanf(filep, "%d", &pkg) != 1) {
1237 perror(path);
1238 exit(1);
1239 }
1231 fclose(filep); 1240 fclose(filep);
1232 return pkg; 1241 return pkg;
1233} 1242}
@@ -1244,7 +1253,10 @@ int get_core_id(int cpu)
1244 perror(path); 1253 perror(path);
1245 exit(1); 1254 exit(1);
1246 } 1255 }
1247 fscanf(filep, "%d", &core); 1256 if (fscanf(filep, "%d", &core) != 1) {
1257 perror(path);
1258 exit(1);
1259 }
1248 fclose(filep); 1260 fclose(filep);
1249 return core; 1261 return core;
1250} 1262}