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

Commit a314e4b8 authored by Jagadeesh Kona's avatar Jagadeesh Kona
Browse files

cpufreq: qcom-cpufreq-hw: Fix possible NULL pointer dereferences



Add checks to properly handle and fix possible NULL pointer
dereferences and avoid usage of uninitialized variables.

Change-Id: I30f1b13ee4988286fbd1856f823858dee81fe5a3
Signed-off-by: default avatarJagadeesh Kona <jkona@codeaurora.org>
parent f532a03c
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -407,6 +407,8 @@ static int qcom_cpufreq_hw_read_lut(struct platform_device *pdev,

	cpu = cpumask_first(&c->related_cpus);

	prev_cc = 0;

	for (i = 0; i < lut_max_entries; i++) {
		data = readl_relaxed(c->base + offsets[REG_FREQ_LUT] +
				      i * lut_row_size);
@@ -440,11 +442,15 @@ static int qcom_cpufreq_hw_read_lut(struct platform_device *pdev,
		prev_cc = core_count;
		prev_freq = freq;

		if (get_cpu_device(cpu))
			dev_pm_opp_add(get_cpu_device(cpu), freq * 1000, volt);
	}

	c->table[i].frequency = CPUFREQ_TABLE_END;
	dev_pm_opp_set_sharing_cpus(get_cpu_device(cpu), &c->related_cpus);

	if (get_cpu_device(cpu))
		dev_pm_opp_set_sharing_cpus(get_cpu_device(cpu),
						&c->related_cpus);

	return 0;
}