All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Gardner <tim.gardner@canonical.com>
To: Jacob Shin <jacob.shin@amd.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	LKML <linux-kernel@vger.kernel.org>,
	cpufreq@vger.kernel.org, linux-pm@vger.kernel.org
Subject: Re: od_set_powersave_bias: NULL pointer dereference
Date: Tue, 25 Jun 2013 12:41:07 -0600	[thread overview]
Message-ID: <51C9E443.8070100@canonical.com> (raw)
In-Reply-To: <20130625161935.GA10208@jshin-Toonie>

On 06/25/2013 10:19 AM, Jacob Shin wrote:
> On Tue, Jun 25, 2013 at 12:26:14PM +0530, Viresh Kumar wrote:
>> On 24 June 2013 22:29, Tim Gardner <tim.gardner@canonical.com> wrote:
>>> This is from Ubuntu Saucy based on 3.10-rc7:
>>>
>>> [   12.911676] BUG: unable to handle kernel NULL pointer dereference at
>>> 0000000000000070
>>> [   12.911691] IP: [<ffffffff8156e572>] od_set_powersave_bias+0x92/0xc0
>>>
>>
>> Can you please look into this bug? It occurred after your
>> patch... This is the boot log crash we have:
> 
> Hi,
> 
> Yes, so sorry about that, it looks like I failed to test with:
> 
> CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
> CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
> CONFIG_CPU_FREQ_GOV_ONDEMAND=y
> CONFIG_X86_AMD_FREQ_SENSITIVITY=m
> 
> The following patch fixes this, Tim, could you please test ? :
> 
> ---8<---
> 
> From 3c727b1f775448599e67c5fb2121d79448e80c90 Mon Sep 17 00:00:00 2001
> From: Jacob Shin <jacob.shin@amd.com>
> Date: Tue, 25 Jun 2013 10:40:54 -0500
> Subject: [PATCH 1/1] cpufreq: fix NULL pointer deference at
>  od_set_powersave_bias()
> 
> When initializing the default powersave_bias value, we need to first
> make sure that this policy is running the ondemand governor.
> 
> Reported-by: Tim Gardner <tim.gardner@canonical.com>
> Signed-off-by: Jacob Shin <jacob.shin@amd.com>
> ---
>  drivers/cpufreq/cpufreq_ondemand.c |   17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
> index 4b9bb5d..93eb5cb 100644
> --- a/drivers/cpufreq/cpufreq_ondemand.c
> +++ b/drivers/cpufreq/cpufreq_ondemand.c
> @@ -47,6 +47,8 @@ static struct od_ops od_ops;
>  static struct cpufreq_governor cpufreq_gov_ondemand;
>  #endif
>  
> +static unsigned int default_powersave_bias;
> +
>  static void ondemand_powersave_bias_init_cpu(int cpu)
>  {
>  	struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu);
> @@ -543,7 +545,7 @@ static int od_init(struct dbs_data *dbs_data)
>  
>  	tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR;
>  	tuners->ignore_nice = 0;
> -	tuners->powersave_bias = 0;
> +	tuners->powersave_bias = default_powersave_bias;
>  	tuners->io_is_busy = should_io_be_busy();
>  
>  	dbs_data->tuners = tuners;
> @@ -585,6 +587,7 @@ static void od_set_powersave_bias(unsigned int powersave_bias)
>  	unsigned int cpu;
>  	cpumask_t done;
>  
> +	default_powersave_bias = powersave_bias;
>  	cpumask_clear(&done);
>  
>  	get_online_cpus();
> @@ -593,11 +596,17 @@ static void od_set_powersave_bias(unsigned int powersave_bias)
>  			continue;
>  
>  		policy = per_cpu(od_cpu_dbs_info, cpu).cdbs.cur_policy;
> -		dbs_data = policy->governor_data;
> -		od_tuners = dbs_data->tuners;
> -		od_tuners->powersave_bias = powersave_bias;
> +		if (!policy)
> +			continue;
>  
>  		cpumask_or(&done, &done, policy->cpus);
> +
> +		if (policy->governor != &cpufreq_gov_ondemand)
> +			continue;
> +
> +		dbs_data = policy->governor_data;
> +		od_tuners = dbs_data->tuners;
> +		od_tuners->powersave_bias = default_powersave_bias;
>  	}
>  	put_online_cpus();
>  }
> 

That appears to have done the trick. You can add my Tested-by.

rtg

-- 
Tim Gardner tim.gardner@canonical.com

  reply	other threads:[~2013-06-25 18:41 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-24 16:59 od_set_powersave_bias: NULL pointer dereference Tim Gardner
2013-06-24 16:59 ` Tim Gardner
2013-06-25  6:56 ` Viresh Kumar
2013-06-25 16:19   ` Jacob Shin
2013-06-25 16:19     ` Jacob Shin
2013-06-25 16:19     ` Jacob Shin
2013-06-25 18:41     ` Tim Gardner [this message]
2013-06-25 22:39       ` Rafael J. Wysocki
2013-06-26  6:48     ` Viresh Kumar
2013-06-26 14:28       ` Jacob Shin
2013-06-26 14:28         ` Jacob Shin
2013-06-26 14:32         ` Viresh Kumar
2013-06-26 14:35           ` Jacob Shin
2013-06-26 14:35             ` Jacob Shin
2013-06-26 17:57           ` Jacob Shin
2013-06-26 17:57             ` Jacob Shin
2013-06-27  7:02             ` Viresh Kumar
2013-06-27 14:55               ` Jacob Shin
2013-06-27 14:55                 ` Jacob Shin
2013-06-27 14:55                 ` Jacob Shin
2013-06-27 15:09                 ` Viresh Kumar
2013-06-27 15:20                   ` Viresh Kumar
2013-06-27 16:22                     ` Jacob Shin
2013-06-27 16:22                       ` Jacob Shin
2013-06-27 16:22                       ` Jacob Shin
2013-06-27 16:23                       ` Viresh Kumar
2013-06-27 15:21                   ` Jacob Shin
2013-06-27 15:21                     ` Jacob Shin
2013-06-27 15:25                     ` Viresh Kumar

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=51C9E443.8070100@canonical.com \
    --to=tim.gardner@canonical.com \
    --cc=cpufreq@vger.kernel.org \
    --cc=jacob.shin@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.