mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-07 03:18:31 +00:00
thermal/drivers/cpufreq_cooling: Remove abusing WARN_ON
The WARN_ON macros are used at the entry functions state2power() and set_cur_state(). state2power() is called with the max_state retrieved from get_max_state which returns cpufreq_cdev->max_level, then it check if max_state is > cpufreq_cdev->max_level. The test does not really makes sense but let's assume we want to make sure to catch an error if the code evolves. However the WARN_ON is overkill. set_cur_state() is also called from userspace if we write to the sysfs. It is easy to see a stack dumped by just writing to sysfs /sys/class/thermal/cooling_device0/cur_state a value greater than "max_level". A bit scary. Returing -EINVAL is enough. Remove these WARN_ON. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Link: https://lore.kernel.org/r/20200321193107.21590-1-daniel.lezcano@linaro.org
This commit is contained in:
parent
ff44f672d7
commit
40ea568593
1 changed files with 2 additions and 2 deletions
|
@ -273,7 +273,7 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev,
|
||||||
struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
|
struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata;
|
||||||
|
|
||||||
/* Request state should be less than max_level */
|
/* Request state should be less than max_level */
|
||||||
if (WARN_ON(state > cpufreq_cdev->max_level))
|
if (state > cpufreq_cdev->max_level)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
num_cpus = cpumask_weight(cpufreq_cdev->policy->cpus);
|
num_cpus = cpumask_weight(cpufreq_cdev->policy->cpus);
|
||||||
|
@ -434,7 +434,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Request state should be less than max_level */
|
/* Request state should be less than max_level */
|
||||||
if (WARN_ON(state > cpufreq_cdev->max_level))
|
if (state > cpufreq_cdev->max_level)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Check if the old cooling action is same as new cooling action */
|
/* Check if the old cooling action is same as new cooling action */
|
||||||
|
|
Loading…
Reference in a new issue