Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Akshay Gupta" <Akshay.Gupta@amd.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v4 2/8] hwmon: sbtsi_temp: Refactor temperature register access into helpers
Date: Fri, 10 Jul 2026 11:30:11 +0000	[thread overview]
Message-ID: <20260710113012.398531F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260710111642.850022-3-Akshay.Gupta@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Setting an extremely high temperature limit in extended range mode causes a signed integer overflow, resulting in the limit being incorrectly clamped to the minimum temperature.
--

--- Patch [2]: [PATCH v4 2/8] hwmon: sbtsi_temp: Refactor temperature register access into helpers ---
commit 64811eaa450f0343a3d3098341243ec7d1df489c
Author: Prathima <Prathima.Lk@amd.com>

hwmon: sbtsi_temp: Refactor temperature register access into helpers

This commit extracts the paired integer and decimal register reads and writes
from the hwmon callbacks into helper functions. It consolidates error
handling and respects the ReadOrder bit to ensure atomic latching.

> diff --git a/drivers/hwmon/sbtsi_temp.c b/drivers/hwmon/sbtsi_temp.c
> index 28258bf499223..078f4ab25bde5 100644
> --- a/drivers/hwmon/sbtsi_temp.c
> +++ b/drivers/hwmon/sbtsi_temp.c

[ ... ]

> @@ -127,11 +169,7 @@ static int sbtsi_write(struct device *dev, enum hwmon_sensor_types type,
>  	val = clamp_val(val, SBTSI_TEMP_MIN, SBTSI_TEMP_MAX);
>  	sbtsi_mc_to_reg(val, &temp_int, &temp_dec);
>  
> -	err = i2c_smbus_write_byte_data(data->client, reg_int, temp_int);
> -	if (err)
> -		return err;
> -
> -	return i2c_smbus_write_byte_data(data->client, reg_dec, temp_dec);
> +	return sbtsi_temp_write(data, reg_int, reg_dec, temp_int, temp_dec);
>  }

[Severity: High]
This isn't a bug introduced by this patch, but can val overflow right before
the clamping happens in sbtsi_write()?

Looking at drivers/hwmon/sbtsi_temp.c around line 168, just above this
diff context:

	if (data->ext_range_mode)
		val += SBTSI_TEMP_EXT_RANGE_ADJ;
	val = clamp_val(val, SBTSI_TEMP_MIN, SBTSI_TEMP_MAX);

If a privileged user writes an extremely high value to the sysfs temperature
limit file (for example, a value near LONG_MAX), adding
SBTSI_TEMP_EXT_RANGE_ADJ to val could cause a signed integer overflow.

This would wrap to a negative value, causing clamp_val() to incorrectly
evaluate it as being below the lower bound and clamp it to SBTSI_TEMP_MIN
instead of SBTSI_TEMP_MAX.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260710111642.850022-1-Akshay.Gupta@amd.com?part=2

  reply	other threads:[~2026-07-10 11:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10 11:16 [PATCH v4 0/8] misc: amd-sbi: Refactor SBTSI driver with I3C support and ioctl interface Akshay Gupta
2026-07-10 11:16 ` [PATCH v4 1/8] hwmon/misc: amd-sbi: Move core sbtsi support from hwmon to misc Akshay Gupta
2026-07-10 11:26   ` sashiko-bot
2026-07-10 14:26   ` Guenter Roeck
2026-07-10 11:16 ` [PATCH v4 2/8] hwmon: sbtsi_temp: Refactor temperature register access into helpers Akshay Gupta
2026-07-10 11:30   ` sashiko-bot [this message]
2026-07-10 14:27   ` Guenter Roeck
2026-07-10 11:16 ` [PATCH v4 3/8] hwmon/misc: amd-sbi: Move sbtsi register transfer to core abstraction Akshay Gupta
2026-07-10 11:25   ` sashiko-bot
2026-07-10 14:28   ` Guenter Roeck
2026-07-10 11:16 ` [PATCH v4 4/8] misc: amd-sbi: Consolidate Common SBTSI Probe Path Akshay Gupta
2026-07-10 11:25   ` sashiko-bot
2026-07-10 11:16 ` [PATCH v4 5/8] misc: amd-sbi: Add support for SB-TSI over I3C Akshay Gupta
2026-07-10 11:34   ` sashiko-bot
2026-07-10 11:16 ` [PATCH v4 6/8] misc: amd-sbi: Add SBTSI ioctl register transfer interface Akshay Gupta
2026-07-10 11:28   ` sashiko-bot
2026-07-10 11:16 ` [PATCH v4 7/8] hwmon: Add mutex protecting for sbtsi read/write through hwmon Akshay Gupta
2026-07-10 11:37   ` sashiko-bot
2026-07-10 14:28   ` Guenter Roeck
2026-07-10 11:16 ` [PATCH v4 8/8] docs: misc: amd-sbi: Document SBTSI userspace interface Akshay Gupta
2026-07-10 11:35   ` sashiko-bot

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=20260710113012.398531F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Akshay.Gupta@amd.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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