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 373d1c742e..e5278cec19 100644
--- a/firmware/target/hosted/cpuinfo-linux.c
+++ b/firmware/target/hosted/cpuinfo-linux.c
@@ -141,13 +141,13 @@ int cpufrequency_linux(int cpu)
141{ 141{
142 char path[64]; 142 char path[64];
143 char temp[10]; 143 char temp[10];
144 int cpu_dev, ret; 144 int cpu_dev, ret = -1;
145 snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_cur_freq", cpu); 145 snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_cur_freq", cpu);
146 cpu_dev = open(path, O_RDONLY); 146 cpu_dev = open(path, O_RDONLY);
147 if (cpu_dev < 0) 147 if (cpu_dev < 0)
148 return -1; 148 return -1;
149 read(cpu_dev, temp, 10); 149 if (read(cpu_dev, temp, sizeof(tmp)) >= 0)
150 ret = atoi(temp); 150 ret = atoi(temp);
151 close(cpu_dev); 151 close(cpu_dev);
152 return ret; 152 return ret;
153} 153}
@@ -156,13 +156,13 @@ int scalingfrequency_linux(int cpu)
156{ 156{
157 char path[64]; 157 char path[64];
158 char temp[10]; 158 char temp[10];
159 int cpu_dev, ret; 159 int cpu_dev, ret = -1;
160 snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", cpu); 160 snprintf(path, sizeof(path), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_cur_freq", cpu);
161 cpu_dev = open(path, O_RDONLY); 161 cpu_dev = open(path, O_RDONLY);
162 if (cpu_dev < 0) 162 if (cpu_dev < 0)
163 return -1; 163 return -1;
164 read(cpu_dev, temp, 10); 164 if (read(cpu_dev, temp, sizeof(tmp)) >= 0)
165 ret = atoi(temp); 165 ret = atoi(temp);
166 close(cpu_dev); 166 close(cpu_dev);
167 return ret; 167 return ret;
168} 168}