]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools/power cpupower: Reset errno before strtoull()
authorKaushlendra Kumar <kaushlendra.kumar@intel.com>
Mon, 1 Dec 2025 12:17:45 +0000 (17:47 +0530)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 15 Dec 2025 19:33:28 +0000 (12:33 -0700)
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>
tools/power/cpupower/lib/cpuidle.c

index 6a881d93d2e991b7aea0b03abf64ab92a4772728..2fcb343d8e757a6f3e1072847b6703a8347d5dc5 100644 (file)
@@ -150,6 +150,7 @@ unsigned long long cpuidle_state_get_one_value(unsigned int cpu,
        if (len == 0)
                return 0;
 
+       errno = 0;
        value = strtoull(linebuf, &endp, 0);
 
        if (endp == linebuf || errno == ERANGE)