linux-stable/drivers/thermal
Dien Pham 31ec38ec9c thermal/drivers/rcar_gen3: Fix undefined temperature if negative
[ Upstream commit 5f8f06425a ]

As description for DIV_ROUND_CLOSEST in file include/linux/kernel.h.
  "Result is undefined for negative divisors if the dividend variable
   type is unsigned and for negative dividends if the divisor variable
   type is unsigned."

In current code, the FIXPT_DIV uses DIV_ROUND_CLOSEST but has not
checked sign of divisor before using. It makes undefined temperature
value in case the value is negative.

This patch fixes to satisfy DIV_ROUND_CLOSEST description
and fix bug too. Note that the variable name "reg" is not good
because it should be the same type as rcar_gen3_thermal_read().
However, it's better to rename the "reg" in a further patch as
cleanup.

Signed-off-by: Van Do <van.do.xw@renesas.com>
Signed-off-by: Dien Pham <dien.pham.ry@renesas.com>
[shimoda: minor fixes, add Fixes tag]
Fixes: 564e73d283 ("thermal: rcar_gen3_thermal: Add R-Car Gen3 thermal driver")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Niklas Soderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Niklas Soderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1593085099-2057-1-git-send-email-yoshihiro.shimoda.uh@renesas.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-07-09 09:37:53 +02:00
..
broadcom thermal: brcmstb_thermal: Do not use DT coefficients 2020-03-05 16:43:50 +01:00
intel Merge branch 'for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux 2019-09-27 11:35:13 -07:00
qcom
samsung
st
tegra
ti-soc-thermal thermal/drivers/ti-soc-thermal: Avoid dereferencing ERR_PTR 2020-06-24 17:50:23 +02:00
armada_thermal.c
clock_cooling.c
cpu_cooling.c cpufreq: Use per-policy frequency QoS 2019-10-21 02:05:21 +02:00
da9062-thermal.c
db8500_thermal.c thermal: db8500: Depromote debug print 2020-03-05 16:43:50 +01:00
devfreq_cooling.c
dove_thermal.c
fair_share.c
gov_bang_bang.c
hisi_thermal.c
imx_thermal.c
Kconfig thermal: db8500: Finalize device tree conversion 2019-09-24 22:54:49 -07:00
kirkwood_thermal.c
Makefile
max77620_thermal.c
mtk_thermal.c thermal/drivers/mediatek: Fix bank number settings on mt8183 2020-07-09 09:37:53 +02:00
of-thermal.c
power_allocator.c
qoriq_thermal.c
rcar_gen3_thermal.c thermal/drivers/rcar_gen3: Fix undefined temperature if negative 2020-07-09 09:37:53 +02:00
rcar_thermal.c
rockchip_thermal.c
spear_thermal.c
step_wise.c
tango_thermal.c
thermal-generic-adc.c
thermal_core.c thermal: Fix deadlock in thermal thermal_zone_device_check 2019-12-13 08:43:21 +01:00
thermal_core.h
thermal_helpers.c
thermal_hwmon.c
thermal_hwmon.h
thermal_mmio.c
thermal_sysfs.c
uniphier_thermal.c
user_space.c
zx2967_thermal.c