[LTP] cpufreq.c: add new test for cpufreq sysfs interface validation
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Wed Apr 22 13:11:39 CEST 2026
Hi Piotr,
On 2026-04-22, Piotr Kubaj wrote:
> cpufreq.c: add new test for cpufreq sysfs interface validation
> +static long *previous_scaling_max_freq, *previous_scaling_min_freq;
> +
> +static void cleanup(void)
> +{
> [...]
> + SAFE_FILE_PRINTF(path, "%ld", previous_scaling_max_freq[i]);
> [...]
> + SAFE_FILE_PRINTF(path, "%ld", previous_scaling_min_freq[i]);
Both arrays are zeroed by SAFE_CALLOC in setup() and only populated
inside run(). If run() aborts before reaching the per-CPU save loops
(e.g. a SAFE_OPEN or SAFE_FILE_SCANF fails on an earlier cpufreq node),
cleanup() writes 0 to scaling_max_freq and scaling_min_freq for every
online CPU, leaving the system in an invalid state.
Read the original per-CPU values in setup() instead.
Pre-existing issues noticed in the surrounding code (not introduced
by this patch):
- cpufreq.c:116 — strstr(contents, "performance powersave") assumes
a specific governor ordering that the kernel does not guarantee.
- cpufreq.c:170 — same issue for "performance schedutil".
---
Note:
Our agent completed the review of the patch.
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list