]> git.ipfire.org Git - thirdparty/linux.git/commit
cpufreq/amd-pstate-ut: Disable dynamic_epp after the mode switch
authorK Prateek Nayak <kprateek.nayak@amd.com>
Sat, 23 May 2026 05:55:03 +0000 (05:55 +0000)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 26 May 2026 10:39:28 +0000 (12:39 +0200)
commitdf488cac6140aa04ae52af9b4507d8f99a3762be
tree096db703879f6b28fac162bd5fc1a628c6b2b41f
parente7ae89a0c97ce2b68b0983cd01eda67cf373517d
cpufreq/amd-pstate-ut: Disable dynamic_epp after the mode switch

Dan reported a possible NULL pointer dereference in amd-pstate-ut.c from
static analysis and sure enough, running amd-pstate-ut in active mode
with amd_dynamic_epp=enable results in a crash as a reult of the policy
reference being set to NULL early, before disabling dynamic EPP.

Kalpana also reported seeing amd-pstate-ut error out with -EBUSY for
"amd_pstate_ut_epp" test when starting from the passive mode and
amd_dynamic_epp=enable in the command line. The reason for the failure
is that the command line enables dynamic_epp by default after the mode
switch and the modifications to EPP values are blocked when running in
dynamic EPP mode.

Solution to both problems is to toggle off dynamic_epp *after* the mode
switch when the driver grabs the policy reference again since the unit
test is in full control of the policy after that point.

The final restoration step will reset the dynamic_epp state via mode
switch based on the initial conditions of the system.

Reported-by: Kalpana Shetty <kalpana.shetty@amd.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/linux-pm/ahEq0CvdBX0T7_cO@stanley.mountain/
Fixes: f9f16835d4dc ("cpufreq/amd-pstate-ut: Drop policy reference before driver switch")
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://patch.msgid.link/20260523055503.7651-1-kprateek.nayak@amd.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/amd-pstate-ut.c