cpufreq: intel_pstate: cancel HWP notify work in driver cleanup
Subsystems (3)
PATCH 1/1 cpufreq: intel_pstate: cancel HWP notify work in driver cleanup
From: Tristan Madani <[email protected]>
intel_pstate_driver_cleanup() frees per-CPU data without cancelling the pending HWP notify delayed work. If hwp_notify_work is still scheduled or running when the struct is freed, the work function accesses freed memory via container_of().
Call intel_pstate_disable_hwp_interrupt() before kfree() to disable the interrupt source and cancel the pending work, matching the pattern used in intel_pstate_suspend() and intel_pstate_hwp_offline().
--- drivers/cpufreq/intel_pstate.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/cpufreq/intel_pstate.c +2 -0
@@ -3436,6 +3436,8 @@ static void intel_pstate_driver_cleanup(void)if (intel_pstate_driver == &intel_pstate)intel_pstate_clear_update_util_hook (cpu); +intel_pstate_disable_hwp_interrupt (all_cpu_data[cpu]); +kfree (all_cpu_data[cpu]);WRITE_ONCE (all_cpu_data[cpu],NULL ); }
Signature · 1 line
2.47.3
Rafael J. Wysocki (Intel)
maintainerQuoted 8 lines · Tristan Madani
From: Tristan Madani <[email protected]>
intel_pstate_driver_cleanup()frees per-CPU data without cancelling the pending HWP notify delayed work. Ifhwp_notify_workis still scheduled or running when the struct is freed, the work function accesses freed memory viacontainer_of().
Quoted 5 lines
Call
intel_pstate_disable_hwp_interrupt()beforekfree()to disable the interrupt source and cancel the pending work, matching the pattern used inintel_pstate_suspend()andintel_pstate_hwp_offline().Fixes d0e936adfe84 ("cpufreq: intel_pstate: Add HWP_HIGHEST_PERF_CHANGE handling")
Where did you get this commit from? It is not a mainline one AFAICS.
Quoted 11 lines
Signed-off-by Tristan Madani <[email protected]>--- drivers/cpufreq/intel_pstate.c | 2 ++ 1 file changed, 2 insertions(+)drivers/cpufreq/intel_pstate.c +0
-0
drivers/cpufreq/intel_pstate.c static void intel_pstate_driver_cleanup(void)
Quoted 9 lines
drivers/cpufreq/intel_pstate.c +2
-1@@ -3436,6 +3436,8 @@ static void intel_pstate_driver_cleanup(void)if (intel_pstate_driver == &intel_pstate)intel_pstate_clear_update_util_hook (cpu); +intel_pstate_disable_hwp_interrupt (all_cpu_data[cpu]); +kfree (all_cpu_data[cpu]);WRITE_ONCE (all_cpu_data[cpu],NULL ); } --
The Fixes: tag replaced with the following one:
performance change interrupt")
and patch applied as 7.4-rc material.
Thanks!