WSL2-Linux-Kernel/drivers/thermal
Manaf Meethalavalappu Pallikunhi 2046a24ae1 thermal/core: Add NULL pointer check before using cooling device stats
There is a possible chance that some cooling device stats buffer
allocation fails due to very high cooling device max state value.
Later cooling device update sysfs can try to access stats data
for the same cooling device. It will lead to NULL pointer
dereference issue.

Add a NULL pointer check before accessing thermal cooling device
stats data. It fixes the following bug

[ 26.812833] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000004
[ 27.122960] Call trace:
[ 27.122963] do_raw_spin_lock+0x18/0xe8
[ 27.122966] _raw_spin_lock+0x24/0x30
[ 27.128157] thermal_cooling_device_stats_update+0x24/0x98
[ 27.128162] cur_state_store+0x88/0xb8
[ 27.128166] dev_attr_store+0x40/0x58
[ 27.128169] sysfs_kf_write+0x50/0x68
[ 27.133358] kernfs_fop_write+0x12c/0x1c8
[ 27.133362] __vfs_write+0x54/0x160
[ 27.152297] vfs_write+0xcc/0x188
[ 27.157132] ksys_write+0x78/0x108
[ 27.162050] ksys_write+0xf8/0x108
[ 27.166968] __arm_smccc_hvc+0x158/0x4b0
[ 27.166973] __arm_smccc_hvc+0x9c/0x4b0
[ 27.186005] el0_svc+0x8/0xc

Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1607367181-24589-1-git-send-email-manafm@codeaurora.org
2021-03-17 09:55:58 +01:00
..
broadcom thermal: broadcom: simplify the return expression of bcm2711_thermal_probe() 2020-12-10 18:29:43 +01:00
intel - Use the newly introduced 'hot' and 'critical' ops for the acpi 2021-02-22 09:39:11 -08:00
qcom thermal: qcom: Fix comparison with uninitialized variable channels_available 2021-02-16 19:05:23 +01:00
samsung
st
tegra
ti-soc-thermal thermal: ti-soc-thermal: Use non-inverted define for omap4 2021-02-15 21:19:32 +01:00
Kconfig thermal/drivers/zx: Remove zx driver 2021-02-03 09:17:47 +01:00
Makefile thermal/drivers/zx: Remove zx driver 2021-02-03 09:17:47 +01:00
amlogic_thermal.c thermal: amlogic: Add hwmon support 2020-11-16 10:30:53 +01:00
armada_thermal.c
cpufreq_cooling.c - Use the newly introduced 'hot' and 'critical' ops for the acpi 2021-02-22 09:39:11 -08:00
cpuidle_cooling.c
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: Fix the build when !ENERGY_MODEL 2020-12-15 17:03:56 +01:00
dove_thermal.c
gov_bang_bang.c
gov_fair_share.c
gov_power_allocator.c thermal: power allocator: fail binding for non-power actor devices 2021-01-19 22:31:10 +01:00
gov_step_wise.c thermal/core: Remove the 'forced_passive' option 2021-01-19 22:22:45 +01:00
gov_user_space.c
hisi_thermal.c
imx8mm_thermal.c thermal: imx8mm: Disable the clock on probe failure 2020-12-04 20:46:03 +01:00
imx_sc_thermal.c
imx_thermal.c
k3_bandgap.c
khadas_mcu_fan.c thermal/core: Make cooling device state change private 2021-01-19 22:31:10 +01:00
kirkwood_thermal.c
max77620_thermal.c
mtk_thermal.c thermal: mtk_thermal: make device_reset optional 2020-10-27 11:19:18 +01:00
qoriq_thermal.c
rcar_gen3_thermal.c thermal: rcar_gen3_thermal: Add r8a779a0 support 2020-12-08 21:18:01 +01:00
rcar_thermal.c thermal/drivers/rcar: Remove notification usage 2020-12-15 17:01:55 +01:00
rockchip_thermal.c
spear_thermal.c
sprd_thermal.c
sun8i_thermal.c thermal: sun8i: Use bitmap API instead of open code 2020-11-12 11:05:12 +01:00
thermal-generic-adc.c
thermal_core.c thermal/core: Remove pointless thermal_zone_device_reset() function 2021-01-19 22:23:49 +01:00
thermal_core.h thermal/core: Make cooling device state change private 2021-01-19 22:31:10 +01:00
thermal_helpers.c thermal/core: Precompute the delays from msecs to jiffies 2021-01-19 22:23:38 +01: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_netlink.c
thermal_netlink.h
thermal_of.c
thermal_sysfs.c thermal/core: Add NULL pointer check before using cooling device stats 2021-03-17 09:55:58 +01:00
uniphier_thermal.c