summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/target/hosted/cpuinfo-linux.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/firmware/target/hosted/cpuinfo-linux.c b/firmware/target/hosted/cpuinfo-linux.c
index 373d1c7..e5278ce 100644
--- a/firmware/target/hosted/cpuinfo-linux.c
+++ b/firmware/target/hosted/cpuinfo-linux.c
@@ -141,13 +141,13 @@ int cpufrequency_linux(int cpu)
{
char path[64];
char temp[10];
- int cpu_dev, ret;
+ int cpu_dev, ret = -1;
snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_cur_freq", cpu);
cpu_dev = open(path, O_RDONLY);
if (cpu_dev < 0)
return -1;
- read(cpu_dev, temp, 10);
- ret = atoi(temp);
+ if (read(cpu_dev, temp, sizeof(tmp)) >= 0)
+ ret = atoi(temp);
close(cpu_dev);
return ret;
}
@@ -156,13 +156,13 @@ int scalingfrequency_linux(int cpu)
{
char path[64];
char temp[10];
- int cpu_dev, ret;
+ int cpu_dev, ret = -1;
snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", cpu);
cpu_dev = open(path, O_RDONLY);
if (cpu_dev < 0)
return -1;
- read(cpu_dev, temp, 10);
- ret = atoi(temp);
+ if (read(cpu_dev, temp, sizeof(tmp)) >= 0)
+ ret = atoi(temp);
close(cpu_dev);
return ret;
}