[LTP] cpufreq.c: add new test for cpufreq sysfs interface validation

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Wed May 6 16:17:49 CEST 2026


Hi Piotr,

On Wed, 6 May 2026, Piotr Kubaj wrote:
> cpufreq.c: add new test for cpufreq sysfs interface validation
>
> Runs various sanity checks for intel_pstate cpufreq sysfs interface.
> [...]

The commit body describes what the test does but not why it is needed.
The motivation ("LTP has no regression coverage for the intel_pstate
cpufreq sysfs interface...") belongs in the commit body, not only in
the in-source doc comment.

> +	fd = SAFE_OPEN(path, O_RDONLY);
> +	SAFE_READ(0, fd, contents, sizeof(contents));
> +	SAFE_CLOSE(fd);

If SAFE_READ fails it calls tst_brk(), skipping SAFE_CLOSE(). cleanup()
has no fd handling so the descriptor leaks. Use SAFE_FILE_SCANF() instead.
This pattern appears twice (~line 184 and ~line 298).

> +static bool setup_done;
[...]
> +	setup_done = true;

setup_done is never reset in cleanup(). With -i, a partial setup failure
on a later iteration sees stale 'true' and incorrectly enters the restore
path. Reset it at the start of setup() or end of cleanup().

---
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