Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>,
	Dan Carpenter <dan.carpenter@linaro.org>,
	 nuno.sa@analog.com
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [bug report] hwmon: ltc4282: add support for the LTC4282 chip
Date: Thu, 08 Feb 2024 09:12:59 +0100	[thread overview]
Message-ID: <9151c5df901325aed61e87019a5a1cffc46cf579.camel@gmail.com> (raw)
In-Reply-To: <c2c5b8b0-d3db-4212-8311-ee54119389c4@roeck-us.net>

On Wed, 2024-02-07 at 08:49 -0800, Guenter Roeck wrote:
> On 2/7/24 02:19, Nuno Sá wrote:
> > 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
> > 
> 
> 	val = clamp_val(val, 0, fs);
> 	in = DIV_ROUND_CLOSEST(val * U8_MAX, fs);
> 
> maybe.
> 
> Should I fix that inline or do you want to send a follow-up patch ?
> 
> Guenter
> 
> 

Whatever makes your life easier... I can send a patch if that is your
preference.

- Nuno Sá

  reply	other threads:[~2024-02-08  8:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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á [this message]
2024-02-08 14:19       ` Guenter Roeck
2024-02-08 15:22         ` Nuno Sá

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9151c5df901325aed61e87019a5a1cffc46cf579.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox