Skip to content

Commit cff8952

Browse files
Xuewen Yanrafaeljw
authored andcommitted
thermal: cpufreq_cooling: Check the policy first in cpufreq_cooling_register()
Since the policy needs to be accessed first when obtaining cpu devices, first check whether the policy is legal before this. Fixes: 5130802 ("thermal: cpu_cooling: Switch to QoS requests for freq limits") Signed-off-by: Xuewen Yan <[email protected]> Acked-by: Viresh Kumar <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 1ea252e commit cff8952

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/thermal/cpufreq_cooling.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,17 +501,17 @@ __cpufreq_cooling_register(struct device_node *np,
501501
struct thermal_cooling_device_ops *cooling_ops;
502502
char *name;
503503

504+
if (IS_ERR_OR_NULL(policy)) {
505+
pr_err("%s: cpufreq policy isn't valid: %p\n", __func__, policy);
506+
return ERR_PTR(-EINVAL);
507+
}
508+
504509
dev = get_cpu_device(policy->cpu);
505510
if (unlikely(!dev)) {
506511
pr_warn("No cpu device for cpu %d\n", policy->cpu);
507512
return ERR_PTR(-ENODEV);
508513
}
509514

510-
if (IS_ERR_OR_NULL(policy)) {
511-
pr_err("%s: cpufreq policy isn't valid: %p\n", __func__, policy);
512-
return ERR_PTR(-EINVAL);
513-
}
514-
515515
i = cpufreq_table_count_valid_entries(policy);
516516
if (!i) {
517517
pr_debug("%s: CPUFreq table not found or has no valid entries\n",

0 commit comments

Comments
 (0)