Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3123d82 authored by Junjie Wu's avatar Junjie Wu
Browse files

cpufreq: stats: Don't update cpufreq_stats_table if it's NULL



When cpufreq_stats_table is not initialized for policy->last_cpu in
CPUFREQ_UPDATE_POLICY_CPU callback, no updates are necessary. Current
implementation dereferences the table unconditionally, causing a crash
if the table is NULL.

Return directly in cpufreq_stats_update_policy_cpu() if
cpufreq_stats_table of policy->last_cpu is NULL.

Change-Id: Ic9ef8120557702791ba5b873532e47cc0a5dc027
Signed-off-by: default avatarJunjie Wu <junjiew@codeaurora.org>
parent ab4b2356
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -275,6 +275,8 @@ static void cpufreq_stats_update_policy_cpu(struct cpufreq_policy *policy)
	struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table,
			policy->last_cpu);

	if (!stat)
		return;
	pr_debug("Updating stats_table for new_cpu %u from last_cpu %u\n",
			policy->cpu, policy->last_cpu);
	per_cpu(cpufreq_stats_table, policy->cpu) = per_cpu(cpufreq_stats_table,