linux-stable/drivers/thermal
Subbaraman Narayanamurthy 96cfe05051 thermal: Fix NULL pointer dereferences in of_thermal_ functions
of_parse_thermal_zones() parses the thermal-zones node and registers a
thermal_zone device for each subnode. However, if a thermal zone is
consuming a thermal sensor and that thermal sensor device hasn't probed
yet, an attempt to set trip_point_*_temp for that thermal zone device
can cause a NULL pointer dereference. Fix it.

 console:/sys/class/thermal/thermal_zone87 # echo 120000 > trip_point_0_temp
 ...
 Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020
 ...
 Call trace:
  of_thermal_set_trip_temp+0x40/0xc4
  trip_point_temp_store+0xc0/0x1dc
  dev_attr_store+0x38/0x88
  sysfs_kf_write+0x64/0xc0
  kernfs_fop_write_iter+0x108/0x1d0
  vfs_write+0x2f4/0x368
  ksys_write+0x7c/0xec
  __arm64_sys_write+0x20/0x30
  el0_svc_common.llvm.7279915941325364641+0xbc/0x1bc
  do_el0_svc+0x28/0xa0
  el0_svc+0x14/0x24
  el0_sync_handler+0x88/0xec
  el0_sync+0x1c0/0x200

While at it, fix the possible NULL pointer dereference in other
functions as well: of_thermal_get_temp(), of_thermal_set_emul_temp(),
of_thermal_get_trend().

Suggested-by: David Collins <quic_collinsd@quicinc.com>
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-11-05 17:35:56 +01:00
..
broadcom thermal/drivers/bcm2835: Remove redundant dev_err call in bcm2835_thermal_probe() 2021-04-20 08:58:47 +02:00
intel Merge branches 'thermal-int340x', 'thermal-powerclamp' and 'thermal-docs' 2021-10-26 15:00:55 +02:00
qcom thermal/drivers/tsens: Add timeout to get_temp_tsens_valid 2021-10-16 20:24:43 +02:00
samsung thermal/drivers/exynos: Fix an error code in exynos_tmu_probe() 2021-08-14 12:40:35 +02:00
st thermal/drivers/st: Use devm_platform_get_and_ioremap_resource() 2021-06-14 19:01:15 +02:00
tegra thermal/drivers/tegra-soctherm: Silence message about clamped temperature 2021-08-14 15:44:15 +02:00
ti-soc-thermal thermal/ti-soc-thermal: Fix kernel-doc 2021-05-24 22:38:05 +02:00
amlogic_thermal.c thermal: amlogic: Omit superfluous error message in amlogic_thermal_probe() 2021-03-10 12:52:55 +01:00
armada_thermal.c
cpufreq_cooling.c thermal/cpufreq_cooling: Update offline CPUs per-cpu thermal_pressure 2021-06-17 14:11:43 +02:00
cpuidle_cooling.c thermal/drivers/cpuidle_cooling: Fix use after error 2021-04-15 13:21:26 +02:00
da9062-thermal.c thermal/core: Remove ms based delay fields 2021-01-19 22:23:49 +01:00
db8500_thermal.c
devfreq_cooling.c thermal/drivers/devfreq_cooling: use HZ macros 2021-09-08 11:50:25 -07:00
dove_thermal.c
gov_bang_bang.c
gov_fair_share.c thermal/core/fair share: Use the lockless __thermal_cdev_update() function 2021-04-22 23:51:32 +02:00
gov_power_allocator.c thermal/core/power allocator: Use the lockless __thermal_cdev_update() function 2021-04-22 23:51:32 +02:00
gov_step_wise.c thermal/core: Remove the 'forced_passive' option 2021-01-19 22:22:45 +01:00
gov_user_space.c thermal/core: Make the userspace governor deprecated 2021-10-21 17:35:05 +02:00
hisi_thermal.c thermal/drivers/hisi: Remove redundant dev_err call in hisi_thermal_probe() 2021-04-20 09:18:57 +02:00
imx8mm_thermal.c thermal: imx8mm: Disable the clock on probe failure 2020-12-04 20:46:03 +01:00
imx_sc_thermal.c thermal/drivers/imx_sc: Add missing of_node_put for loop iteration 2021-06-14 22:41:00 +02:00
imx_thermal.c thermal: imx: Use dev_err_probe() to simplify error handling 2020-10-12 12:08:34 +02:00
k3_bandgap.c
Kconfig thermal/drivers/zx: Remove zx driver 2021-02-03 09:17:47 +01:00
khadas_mcu_fan.c thermal/core: Make cooling device state change private 2021-01-19 22:31:10 +01:00
kirkwood_thermal.c
Makefile thermal/drivers/zx: Remove zx driver 2021-02-03 09:17:47 +01:00
max77620_thermal.c
mtk_thermal.c thermal/drivers/mediatek: Add sensors-support 2021-07-04 18:28:04 +02:00
qoriq_thermal.c
rcar_gen3_thermal.c thermal: rcar_gen3_thermal: Read calibration from hardware 2021-10-15 09:15:52 +02:00
rcar_thermal.c thermal/drivers/rcar: Remove notification usage 2020-12-15 17:01:55 +01:00
rockchip_thermal.c thermal/drivers/rockchip_thermal: Allow more resets for tsadc node 2021-10-17 00:15:09 +02:00
spear_thermal.c
sprd_thermal.c thermal/drivers/sprd: Add missing of_node_put for loop iteration 2021-06-14 22:42:09 +02:00
sun8i_thermal.c thermal: Fix couple of spellos in the file sun8i_thermal.c 2021-03-10 12:54:58 +01:00
thermal-generic-adc.c
thermal_core.c thermal/core: fix a UAF bug in __thermal_cooling_device_register() 2021-10-15 15:38:48 +02:00
thermal_core.h thermal/core: Create a helper __thermal_cdev_update() without a lock 2021-04-22 14:10:28 +02:00
thermal_helpers.c thermal/core: Create a helper __thermal_cdev_update() without a lock 2021-04-22 14:10:28 +02:00
thermal_hwmon.c thermal/drivers/hwmon: Cleanup coding style a bit 2020-11-12 11:24:01 +01:00
thermal_hwmon.h
thermal_mmio.c thermal/drivers/thermal_mmio: Constify static struct thermal_mmio_ops 2021-10-07 15:18:31 +02:00
thermal_netlink.c thermal/drivers/netlink: Add the temperature when crossing a trip point 2021-10-07 15:41:38 +02:00
thermal_netlink.h thermal/drivers/netlink: Add the temperature when crossing a trip point 2021-10-07 15:41:38 +02:00
thermal_of.c thermal: Fix NULL pointer dereferences in of_thermal_ functions 2021-11-05 17:35:56 +01:00
thermal_sysfs.c thermal/core: Deprecate changing cooling device state from userspace 2021-10-21 17:35:11 +02:00
uniphier_thermal.c thermal/drivers/uniphier: Add compatible string for NX1 SoC 2021-10-18 14:00:13 +02:00