tools/power cpupower: Reset errno before strtoull()

[ Upstream commit f9bd3762cf1bd0c2465f2e6121b340883471d1bf ]

cpuidle_state_get_one_value() never cleared errno before calling
strtoull(), so a prior ERANGE caused every cpuidle counter read to
return zero. Reset errno to 0 before the conversion so each sysfs read
is evaluated independently.

Link: https://lore.kernel.org/r/20251201121745.3776703-1-kaushlendra.kumar@intel.com
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
This commit is contained in:
Kaushlendra Kumar authored and Ulrich Hecht committed 2026-04-12 13:56:45 +08:00
1 parent aed06b0e7d
commit dc68972a33
1 file changed
+1
+1
View File
@@ -149,6 +149,7 @@ unsigned long long cpuidle_state_get_one_value(unsigned int cpu,
if (len == 0) if (len == 0)
return 0; return 0;
errno = 0;
value = strtoull(linebuf, &endp, 0); value = strtoull(linebuf, &endp, 0);
if (endp == linebuf || errno == ERANGE) if (endp == linebuf || errno == ERANGE)