Re: [bug report] hwmon: ltc4282: add support for the LTC4282 chip

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

 



Hi Dan,

On Wed, 2024-02-07 at 12:51 +0300, Dan Carpenter wrote:
> Hello Nuno Sa,
> 
> The patch 848a5019ded5: "hwmon: ltc4282: add support for the LTC4282
> chip" from Jan 29, 2024 (linux-next), leads to the following Smatch
> static checker warning:
> 
> 	drivers/hwmon/ltc4282.c:732 ltc4282_write_voltage_byte_cached()
> 	warn: no lower bound on 'val' rl='s64min-4294967294'
> 
> drivers/hwmon/ltc4282.c
>     723 static int ltc4282_write_voltage_byte_cached(const struct
> ltc4282_state *st,
>     724                                              u32 reg, u32 fs, long
> val,
>     725                                              u32 *cache_raw)
>     726 {
>     727         u32 in;
>     728 
>     729         if (val >= fs)
>     730                 in = U8_MAX;
>     731         else
> --> 732                 in = DIV_ROUND_CLOSEST(val * U8_MAX, fs);

Yeah, I guess we should likely clamp it between 0 and fs

- Nuno Sá





[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux