Linux Hardware Monitor development
 help / color / mirror / Atom feed
* [bug report] hwmon: ltc4282: add support for the LTC4282 chip
@ 2024-02-07  9:51 Dan Carpenter
  2024-02-07 10:19 ` Nuno Sá
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2024-02-07  9:51 UTC (permalink / raw)
  To: nuno.sa; +Cc: linux-hwmon

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-08 15:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-07  9:51 [bug report] hwmon: ltc4282: add support for the LTC4282 chip Dan Carpenter
2024-02-07 10:19 ` Nuno Sá
2024-02-07 16:49   ` Guenter Roeck
2024-02-08  8:12     ` Nuno Sá
2024-02-08 14:19       ` Guenter Roeck
2024-02-08 15:22         ` Nuno Sá

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox