diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2022-10-17 13:03:01 +0300 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2022-10-25 19:58:11 +0300 |
commit | c408b3d1d9bbc7de5fb0304fea424ef2539da616 (patch) | |
tree | 4df01a831c649894ec6666e0e5758b5ccbe457e1 /drivers/thermal/gov_fair_share.c | |
parent | 247f34f7b80357943234f93f247a1ae6b6c3a740 (diff) | |
download | linux-c408b3d1d9bbc7de5fb0304fea424ef2539da616.tar.xz |
thermal: Validate new state in cur_state_store()
In cur_state_store(), the new state of the cooling device is received
from user-space and is not validated by the thermal core but the same is
left for the individual drivers to take care of. Apart from duplicating
the code it leaves possibility for introducing bugs where a driver may
not do it right.
Lets make the thermal core check the new state itself and store the max
value in the cooling device structure.
Link: https://lore.kernel.org/all/Y0ltRJRjO7AkawvE@kili/
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/thermal/gov_fair_share.c')
-rw-r--r-- | drivers/thermal/gov_fair_share.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_share.c index a4ee4661e9cc..1cfeac16e7ac 100644 --- a/drivers/thermal/gov_fair_share.c +++ b/drivers/thermal/gov_fair_share.c @@ -49,11 +49,7 @@ static int get_trip_level(struct thermal_zone_device *tz) static long get_target_state(struct thermal_zone_device *tz, struct thermal_cooling_device *cdev, int percentage, int level) { - unsigned long max_state; - - cdev->ops->get_max_state(cdev, &max_state); - - return (long)(percentage * level * max_state) / (100 * tz->num_trips); + return (long)(percentage * level * cdev->max_state) / (100 * tz->num_trips); } /** |