mbox series

[0/2] thermal: Validate new state in cur_state_store()

Message ID cover.1666000867.git.viresh.kumar@linaro.org
Headers show
Series thermal: Validate new state in cur_state_store() | expand

Message

Viresh Kumar Oct. 17, 2022, 10:03 a.m. UTC
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.

Once this is merged, I will update the thermal drivers to stop checking
for the same.

Based of v6.1-rc1.

Viresh Kumar (2):
  thermal: Validate new state in cur_state_store()
  thermal: sysfs: Reuse cdev->max_state

 drivers/thermal/gov_fair_share.c |  6 +-----
 drivers/thermal/thermal_core.c   | 15 ++++++-------
 drivers/thermal/thermal_sysfs.c  | 37 +++++++++++++-------------------
 include/linux/thermal.h          |  1 +
 4 files changed, 24 insertions(+), 35 deletions(-)

Comments

Rafael J. Wysocki Oct. 25, 2022, 4:59 p.m. UTC | #1
On Mon, Oct 17, 2022 at 12:03 PM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> 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.
>
> Once this is merged, I will update the thermal drivers to stop checking
> for the same.
>
> Based of v6.1-rc1.
>
> Viresh Kumar (2):
>   thermal: Validate new state in cur_state_store()
>   thermal: sysfs: Reuse cdev->max_state
>
>  drivers/thermal/gov_fair_share.c |  6 +-----
>  drivers/thermal/thermal_core.c   | 15 ++++++-------
>  drivers/thermal/thermal_sysfs.c  | 37 +++++++++++++-------------------
>  include/linux/thermal.h          |  1 +
>  4 files changed, 24 insertions(+), 35 deletions(-)
>
> --

Both patches in the series applied as 6.2 material, thanks!