]> xenbits.xensource.com Git - xen.git/commitdiff
cpufreq: don't leave stale statistics pointer
authorJan Beulich <jbeulich@suse.com>
Wed, 30 Apr 2025 06:47:49 +0000 (08:47 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 30 Apr 2025 06:47:49 +0000 (08:47 +0200)
Error paths of cpufreq_statistic_init() correctly free the base
structure pointer, but the per-CPU variable would still hold it, mis-
guiding e.g. cpufreq_statistic_update(). Defer installing of the pointer
there until the structure was fully populated.

Fixes: 755af07edba1 ("x86/cpufreq: don't use static array for large per-CPU data structures")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/drivers/cpufreq/utility.c

index ac2889d496d40ecdaf95f89c635d1fc41c921c16..309c0682cfe4991f53e9f4e407e60eeddda2954c 100644 (file)
@@ -113,7 +113,6 @@ int cpufreq_statistic_init(unsigned int cpu)
         spin_unlock(cpufreq_statistic_lock);
         return -ENOMEM;
     }
-    per_cpu(cpufreq_statistic_data, cpu) = pxpt;
 
     pxpt->u.trans_pt = xzalloc_array(uint64_t, count * count);
     if (!pxpt->u.trans_pt) {
@@ -139,6 +138,8 @@ int cpufreq_statistic_init(unsigned int cpu)
     pxpt->prev_state_wall = NOW();
     pxpt->prev_idle_wall = get_cpu_idle_time(cpu);
 
+    per_cpu(cpufreq_statistic_data, cpu) = pxpt;
+
     spin_unlock(cpufreq_statistic_lock);
 
     return 0;