]> git.baikalelectronics.ru Git - kernel.git/commit
thermal: Validate new state in cur_state_store()
authorViresh Kumar <viresh.kumar@linaro.org>
Mon, 17 Oct 2022 10:03:01 +0000 (15:33 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Feb 2023 07:34:26 +0000 (08:34 +0100)
commit29e306d8f7b6d830952160274bbbf5532b5f2309
tree4f7b577d0be00d49c9eb7046f7133dc09f5a4f6b
parent5a81b2e22d9a7c1de37cde750cf5996c1da8c9b9
thermal: Validate new state in cur_state_store()

[ Upstream commit 743160b98189306301db721e95dd9ccc1ad58fff ]

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>
Stable-dep-of: f165a55dea80 ("thermal: core: call put_device() only after device_register() fails")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/thermal/gov_fair_share.c
drivers/thermal/thermal_core.c
drivers/thermal/thermal_sysfs.c
include/linux/thermal.h