From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Henry Willard <henry.willard@oracle.com>
Cc: viresh.kumar@linaro.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpufreq: governor: Protect cpufreq governor_data
Date: Mon, 20 Aug 2018 11:07:49 +0200 [thread overview]
Message-ID: <2923321.jmYcvy9DfS@aspire.rjw.lan> (raw)
In-Reply-To: <1534291262-4207-1-git-send-email-henry.willard@oracle.com>
On Wednesday, August 15, 2018 2:01:02 AM CEST Henry Willard wrote:
> 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.
>
> Signed-off-by: Henry Willard <henry.willard@oracle.com>
> ---
> drivers/cpufreq/cpufreq_governor.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
> index 1d50e97d49f1..43416ee55849 100644
> --- a/drivers/cpufreq/cpufreq_governor.c
> +++ b/drivers/cpufreq/cpufreq_governor.c
> @@ -555,12 +555,20 @@ void cpufreq_dbs_governor_stop(struct cpufreq_policy *policy)
>
> 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);
>
Applied, thanks!
next prev parent reply other threads:[~2018-08-20 9:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-15 0:01 Henry Willard
2018-08-20 9:07 ` Rafael J. Wysocki [this message]
2018-09-13 14:29 ` Jeremy Cline
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2923321.jmYcvy9DfS@aspire.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=henry.willard@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®