WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH]Make sure processor_pminfo initialized before use

To: "Yang Z Zhang" <yang.z.zhang@xxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH]Make sure processor_pminfo initialized before use it
From: "Jan Beulich" <JBeulich@xxxxxxxx>
Date: Thu, 08 Sep 2011 10:12:44 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, Keir Fraser <keir@xxxxxxx>
Delivery-date: Thu, 08 Sep 2011 02:13:40 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <749B9D3DBF0F054390025D9EAFF47F2212D149D959@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <749B9D3DBF0F054390025D9EAFF47F2212D149D959@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
>>> On 08.09.11 at 08:09, "Zhang, Yang Z" <yang.z.zhang@xxxxxxxxx> wrote:
> Make sure processor_pminfo not null before use it
> 
> If processor_pminfo not initialized, it will cause xen panic.

Mind pointing out what panic you observed, because ...

> Signed-off-by: Yang Zhang <yang.z.zhang@xxxxxxxxx>
> 
> diff -r bdd19847ae63 xen/drivers/cpufreq/cpufreq.c
> --- a/xen/drivers/cpufreq/cpufreq.c     Wed Sep 07 10:37:48 2011 +0100
> +++ b/xen/drivers/cpufreq/cpufreq.c     Thu Sep 08 13:40:23 2011 +0800
> @@ -91,7 +91,7 @@ int __init cpufreq_register_governor(str
> 
>  int cpufreq_limit_change(unsigned int cpu)
>  {
> -    struct processor_performance *perf = &processor_pminfo[cpu]->perf;
> +    struct processor_performance *perf;

... this (and all other changed instances below) is not actually
de-referencing processor_pminfo[cpu], and the first de-reference
always is only after that one got checked against NULL.

Jan

>      struct cpufreq_policy *data;
>      struct cpufreq_policy policy;
> 
> @@ -99,6 +99,7 @@ int cpufreq_limit_change(unsigned int cp
>          !processor_pminfo[cpu])
>          return -ENODEV;
> 
> +    perf = &processor_pminfo[cpu]->perf;
>      if (perf->platform_limit >= perf->state_count)
>          return -EINVAL;
> 
> @@ -120,12 +121,14 @@ int cpufreq_add_cpu(unsigned int cpu)
>      struct cpufreq_dom *cpufreq_dom = NULL;
>      struct cpufreq_policy new_policy;
>      struct cpufreq_policy *policy;
> -    struct processor_performance *perf = &processor_pminfo[cpu]->perf;
> +    struct processor_performance *perf;
> 
>      /* to protect the case when Px was not controlled by xen */
> -    if (!processor_pminfo[cpu]      ||
> -        !(perf->init & XEN_PX_INIT) ||
> -        !cpu_online(cpu))
> +    if (!processor_pminfo[cpu] || !cpu_online(cpu))
> +        return -EINVAL;
> +
> +    perf = &processor_pminfo[cpu]->perf;
> +    if (!(perf->init & XEN_PX_INIT))
>          return -EINVAL;
> 
>      if (!cpufreq_driver)
> @@ -261,12 +264,14 @@ int cpufreq_del_cpu(unsigned int cpu)
>      struct list_head *pos;
>      struct cpufreq_dom *cpufreq_dom = NULL;
>      struct cpufreq_policy *policy;
> -    struct processor_performance *perf = &processor_pminfo[cpu]->perf;
> +    struct processor_performance *perf;
> 
>      /* to protect the case when Px was not controlled by xen */
> -    if (!processor_pminfo[cpu]      ||
> -        !(perf->init & XEN_PX_INIT) ||
> -        !cpu_online(cpu))
> +    if (!processor_pminfo[cpu] || !cpu_online(cpu))
> +        return -EINVAL;
> +
> +    perf = &processor_pminfo[cpu]->perf;
> +    if (!(perf->init & XEN_PX_INIT))
>          return -EINVAL;
> 
>      if (!per_cpu(cpufreq_cpu_policy, cpu))
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx 
> http://lists.xensource.com/xen-devel 




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>