FAILED: patch "[PATCH] cpufreq: governor: Avoid accessing invalid governor_data" failed to apply to 4.9-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.9-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
2a3eb51e30b9ac66fe1b75877627a7e4aaeca24aMon Sep 17 00:00:00 2001
From: Henry Willard <[email protected]>
Date: Tue, 14 Aug 2018 17:01:02 -0700
Subject: [PATCH] cpufreq: governor: Avoid accessing invalid governor_data
If cppc_cpufreq.ko is deleted at the same time that tuned-adm is changing profiles, there is a small chance that a race can occur between cpufreq_dbs_governor_exit() and cpufreq_dbs_governor_limits() resulting in a system failure when the latter tries to use policy->governor_data that has been freed by the former.
This patch uses gov_dbs_data_mutex to synchronize access.
drivers/cpufreq/cpufreq_governor.c +10 -2
@@ -555,12 +555,20 @@ EXPORT_SYMBOL_GPL(cpufreq_dbs_governor_stop);void cpufreq_dbs_governor_limits (struct cpufreq_policy *policy) { -struct policy_dbs_info *policy_dbs = policy->governor_data; +struct policy_dbs_info *policy_dbs; + +/* Protect gov->gdbs_data against cpufreq_dbs_governor_exit() */ +mutex_lock (&gov_dbs_data_mutex); + policy_dbs = policy->governor_data; +if (!policy_dbs) + goto out;mutex_lock (&policy_dbs->update_mutex);cpufreq_policy_apply_limits (policy);gov_update_sample_delay (policy_dbs,0 ); -mutex_unlock (&policy_dbs->update_mutex); + +out: +mutex_unlock (&gov_dbs_data_mutex); }EXPORT_SYMBOL_GPL (cpufreq_dbs_governor_limits);