Re: [PATCH 1/1] fix cpufreq/cpufreq.c null pointer access issue

From: Viresh Kumar
Date: Mon Aug 31 2015 - 03:19:30 EST


On 29-08-15, 01:32, ää wrote:
> Hi,
> This patch fixes an issue in cpufreq_init_policy().
>
> Best regards,
> Yu Wei

You have done the right thing in the wrong way.

Firstly, this is not how you send patches. Please read
Documentation/SubmittingPatches for right details..

Secondly, this is even more screwed up as you sent it as html :)

> Subject: [PATCH] cpufreq: print the last governor while restoring governor
>
> Commit 35afd02e30d6 ("cpufreq: Initialize the governor again while
> restoring policy") clears policy->governor to initialize the governor

This isn't the patch which broke it, but this one:

6e2c89d16d98 ("cpufreq: move call to __find_governor() to cpufreq_init_policy()")

> while restoring governor. The policy->governor is NULL and
> find_governor() returns last used governor matching last_governor
> string, so print last_governor instead of policy->governor->name.
>

Add this line here:

Fixes: 6e2c89d16d98 ("cpufreq: move call to __find_governor() to cpufreq_init_policy()")

> Signed-off-by: Yu Wei <yuweieric@xxxxxxx>
>
> ---
> drivers/cpufreq/cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 7a3c30c..5a9e50e 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1072,7 +1072,7 @@ static void cpufreq_init_policy(struct cpufreq_policy
> *policy)
> gov = find_governor(policy->last_governor);
> if (gov)
> pr_debug("Restoring governor %s for cpu %d\n",
> - policy->governor->name, policy->cpu);
> + policy->last_governor, policy->cpu);

The right thing to do here is to print gov->name instead.

> else
> gov = CPUFREQ_DEFAULT_GOVERNOR;
>
> --
> 1.9.1
>
> SECURITY NOTE: file ~/.netrc must not be accessible by others

--
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/