cpufreq: don't leave stale statistics pointer

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: 755af07edb ("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>
master commit: a1ce987411
master date: 2025-04-30 08:47:49 +0200
This commit is contained in:
Jan Beulich committed 2025-05-13 14:01:00 +02:00
1 parent a150ecceee
commit 0bf71d5c22
1 file changed
+2 -1
+2 -1
View File
@@ -114,7 +114,6 @@ int cpufreq_statistic_init(unsigned int cpuid)
spin_unlock(cpufreq_statistic_lock);
return -ENOMEM;
}
per_cpu(cpufreq_statistic_data, cpuid) = pxpt;
pxpt->u.trans_pt = xzalloc_array(uint64_t, count * count);
if (!pxpt->u.trans_pt) {
@@ -140,6 +139,8 @@ int cpufreq_statistic_init(unsigned int cpuid)
pxpt->prev_state_wall = NOW();
pxpt->prev_idle_wall = get_cpu_idle_time(cpuid);
per_cpu(cpufreq_statistic_data, cpuid) = pxpt;
spin_unlock(cpufreq_statistic_lock);
return 0;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.