[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140102232638.GA21548@core.coreip.homeip.net>
Date: Thu, 2 Jan 2014 15:26:38 -0800
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: jiel@...vell.com
Cc: rjw@...ysocki.net, viresh.kumar@...aro.org,
cpufreq@...r.kernel.org, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] cpufreq: Fix timer/workqueue corruption by protecting
reading governor_enabled
Hi Jane:
On Thu, Jan 02, 2014 at 11:14:42AM +0800, jiel@...vell.com wrote:
> @@ -119,8 +121,11 @@ void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy,
> {
> int i;
>
> - if (!policy->governor_enabled)
> + mutex_lock(&cpufreq_governor_lock);
> + if (!policy->governor_enabled) {
> + mutex_unlock(&cpufreq_governor_lock);
> return;
> + }
>
> if (!all_cpus) {
> /*
> @@ -135,6 +140,7 @@ void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy,
> for_each_cpu(i, policy->cpus)
> __gov_queue_work(i, dbs_data, delay);
> }
> + mutex_unlock(&cpufreq_governor_lock);
Unlocking in different branches is not the best practice IMO, I'd
recommend doing:
mutex_lock(&cpufreq_governor_lock);
if (!policy->governor_enabled)
goto out_unlock;
...
out_unlock:
mutex_unlock(&cpufreq_governor_lock);
Thanks!
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists