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

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

 



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);

It looks like val comes from the user via hwmon_attr_store().  Do we
need to check if it's negative?

    733 
    734         if (cache_raw) {
    735                 *cache_raw = in;
    736                 return 0;
    737         }
    738 
    739         return regmap_write(st->map, reg, in);
    740 }

regards,
dan carpenter




[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