thermal: cpufreq_cooling: Check the policy first in cpufreq_cooling_register()
[linux-2.6-microblaze.git] / drivers / thermal / cpufreq_cooling.c
index b76293c..7838b6e 100644 (file)
@@ -501,17 +501,17 @@ __cpufreq_cooling_register(struct device_node *np,
        struct thermal_cooling_device_ops *cooling_ops;
        char *name;
 
+       if (IS_ERR_OR_NULL(policy)) {
+               pr_err("%s: cpufreq policy isn't valid: %p\n", __func__, policy);
+               return ERR_PTR(-EINVAL);
+       }
+
        dev = get_cpu_device(policy->cpu);
        if (unlikely(!dev)) {
                pr_warn("No cpu device for cpu %d\n", policy->cpu);
                return ERR_PTR(-ENODEV);
        }
 
-       if (IS_ERR_OR_NULL(policy)) {
-               pr_err("%s: cpufreq policy isn't valid: %p\n", __func__, policy);
-               return ERR_PTR(-EINVAL);
-       }
-
        i = cpufreq_table_count_valid_entries(policy);
        if (!i) {
                pr_debug("%s: CPUFreq table not found or has no valid entries\n",