From: Dmitry Osipenko <digetx@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>,
Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Jean Delvare <jdelvare@suse.com>
Subject: Re: [PATCH 2/5] hwmon: (lm90) Prevent integer overflow/underflow in hysteresis calculations
Date: Sat, 11 Dec 2021 00:08:19 +0300 [thread overview]
Message-ID: <0f9b61eb-7cd9-654a-e526-8a6f8d2c0533@gmail.com> (raw)
In-Reply-To: <20211210200136.1662127-3-linux@roeck-us.net>
10.12.2021 23:01, Guenter Roeck пишет:
> Commit b50aa49638c7 ("hwmon: (lm90) Prevent integer underflows of
> temperature calculations") addressed a number of underflow situations
> when writing temperature limits. However, it missed one situation, seen
> when an attempt is made to set the hysteresis value to MAX_LONG and the
> critical temperature limit is negative.
>
> Use clamp_val() when setting the hysteresis temperature to ensure that
> the provided value can never overflow or underflow.
>
> Fixes: b50aa49638c7 ("hwmon: (lm90) Prevent integer underflows of temperature calculations")
> Cc: Dmitry Osipenko <digetx@gmail.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/hwmon/lm90.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index b05d73c4fbe2..72969ea83d82 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -1160,8 +1160,8 @@ static int lm90_set_temphyst(struct lm90_data *data, long val)
> else
> temp = temp_from_s8(data->temp8[LOCAL_CRIT]);
>
> - /* prevent integer underflow */
> - val = max(val, -128000l);
> + /* prevent integer overflow/underflow */
> + val = clamp_val(val, -128000l, 255000l);
>
> data->temp_hyst = hyst_to_reg(temp - val);
> err = i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST,
>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
next prev parent reply other threads:[~2021-12-10 21:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-10 20:01 [PATCH 0/5] hwmon: (lm90) Various fixes Guenter Roeck
2021-12-10 20:01 ` [PATCH 1/5] hwmon: (lm90) Fix usage of CONFIG2 register in detect function Guenter Roeck
2021-12-10 20:01 ` [PATCH 2/5] hwmon: (lm90) Prevent integer overflow/underflow in hysteresis calculations Guenter Roeck
2021-12-10 21:08 ` Dmitry Osipenko [this message]
2021-12-10 20:01 ` [PATCH 3/5] hwmon: (lm90) Drop critical attribute support for MAX6654 Guenter Roeck
2021-12-10 20:01 ` [PATCH 4/5] hwmom: (lm90) Fix citical alarm status for MAX6680/MAX6681 Guenter Roeck
2021-12-10 20:01 ` [PATCH 5/5] hwmon: (lm90) Do not report 'busy' status bit as alarm Guenter Roeck
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=0f9b61eb-7cd9-654a-e526-8a6f8d2c0533@gmail.com \
--to=digetx@gmail.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
/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