Re: [PATCH v3] thermal: rcar_gen3_thermal: Fix undefined temperature if negative

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

On 25.06.2020 5:56, Yoshihiro Shimoda wrote:

From: Dien Pham <dien.pham.ry@xxxxxxxxxxx>

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, there is better to rename it in a further patch as

   It's better.

cleanup.

Signed-off-by: Van Do <van.do.xw@xxxxxxxxxxx>
Signed-off-by: Dien Pham <dien.pham.ry@xxxxxxxxxxx>
[shimoda: minor fixes, add Fixes tag]
Fixes: 564e73d283af ("thermal: rcar_gen3_thermal: Add R-Car Gen3 thermal driver")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>
Reviewed-by: Niklas Soderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>
Tested-by: Niklas Soderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>
[...]

MBR, Sergei



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux