mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-10 07:00:48 +00:00
ACPI: processor: Avoid NULL pointer dereferences at init time
If there are neither processor objects nor processor device objects in the ACPI tables, the per-CPU processors table will not be initialized and attempting to dereference pointers from there will cause the kernel to crash. This happens in acpi_processor_ppc_init() and acpi_thermal_cpufreq_init() after commit d15ce412737a ("ACPI: cpufreq: Switch to QoS requests instead of cpufreq notifier") which didn't add the requisite NULL pointer checks in there. Add the NULL pointer checks to acpi_processor_ppc_init() and acpi_thermal_cpufreq_init(), and to the corresponding "exit" routines. While at it, drop redundant return instructions from acpi_processor_ppc_init() and acpi_thermal_cpufreq_init(). Fixes: d15ce412737a ("ACPI: cpufreq: Switch to QoS requests instead of cpufreq notifier") Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
parent
65650b3513
commit
2d8b39a62a
@ -162,20 +162,22 @@ void acpi_processor_ppc_init(int cpu)
|
|||||||
struct acpi_processor *pr = per_cpu(processors, cpu);
|
struct acpi_processor *pr = per_cpu(processors, cpu);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!pr)
|
||||||
|
return;
|
||||||
|
|
||||||
ret = dev_pm_qos_add_request(get_cpu_device(cpu),
|
ret = dev_pm_qos_add_request(get_cpu_device(cpu),
|
||||||
&pr->perflib_req, DEV_PM_QOS_MAX_FREQUENCY,
|
&pr->perflib_req, DEV_PM_QOS_MAX_FREQUENCY,
|
||||||
INT_MAX);
|
INT_MAX);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
pr_err("Failed to add freq constraint for CPU%d (%d)\n", cpu,
|
pr_err("Failed to add freq constraint for CPU%d (%d)\n", cpu,
|
||||||
ret);
|
ret);
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void acpi_processor_ppc_exit(int cpu)
|
void acpi_processor_ppc_exit(int cpu)
|
||||||
{
|
{
|
||||||
struct acpi_processor *pr = per_cpu(processors, cpu);
|
struct acpi_processor *pr = per_cpu(processors, cpu);
|
||||||
|
|
||||||
|
if (pr)
|
||||||
dev_pm_qos_remove_request(&pr->perflib_req);
|
dev_pm_qos_remove_request(&pr->perflib_req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,20 +130,22 @@ void acpi_thermal_cpufreq_init(int cpu)
|
|||||||
struct acpi_processor *pr = per_cpu(processors, cpu);
|
struct acpi_processor *pr = per_cpu(processors, cpu);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!pr)
|
||||||
|
return;
|
||||||
|
|
||||||
ret = dev_pm_qos_add_request(get_cpu_device(cpu),
|
ret = dev_pm_qos_add_request(get_cpu_device(cpu),
|
||||||
&pr->thermal_req, DEV_PM_QOS_MAX_FREQUENCY,
|
&pr->thermal_req, DEV_PM_QOS_MAX_FREQUENCY,
|
||||||
INT_MAX);
|
INT_MAX);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
pr_err("Failed to add freq constraint for CPU%d (%d)\n", cpu,
|
pr_err("Failed to add freq constraint for CPU%d (%d)\n", cpu,
|
||||||
ret);
|
ret);
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void acpi_thermal_cpufreq_exit(int cpu)
|
void acpi_thermal_cpufreq_exit(int cpu)
|
||||||
{
|
{
|
||||||
struct acpi_processor *pr = per_cpu(processors, cpu);
|
struct acpi_processor *pr = per_cpu(processors, cpu);
|
||||||
|
|
||||||
|
if (pr)
|
||||||
dev_pm_qos_remove_request(&pr->thermal_req);
|
dev_pm_qos_remove_request(&pr->thermal_req);
|
||||||
}
|
}
|
||||||
#else /* ! CONFIG_CPU_FREQ */
|
#else /* ! CONFIG_CPU_FREQ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user