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

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

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH]Make sure processor_pminfo initialized before use it
From: "Zhang, Yang Z" <yang.z.zhang@xxxxxxxxx>
Date: Thu, 8 Sep 2011 14:09:31 +0800
Accept-language: en-US
Acceptlanguage: en-US
Cc: "'Keir Fraser \(keir.xen@xxxxxxxxx\)'" <keir.xen@xxxxxxxxx>
Delivery-date: Wed, 07 Sep 2011 23:11:25 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: Acxt7d9Yhjx7d4VVRwqjgdG2VuXt/Q==
Thread-topic: [PATCH]Make sure processor_pminfo initialized before use it
Make sure processor_pminfo not null before use it

If processor_pminfo not initialized, it will cause xen panic.

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;
     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

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