From: sashiko-bot@kernel.org
To: "Christopher de Guzman" <christopher.deguzman@analog.com>
Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/3] hwmon: (pmbus/ltc2978) Add support for LT7175 and LT7176P
Date: Tue, 20 Oct 2026 12:01:01 +0000 [thread overview]
Message-ID: <sashiko-outbox-178914@kernel.org> (raw)
In-Reply-To: <20261020-upstream-lt7175-lt7176p-v1-2-86b9b728b95d@analog.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] hwmon: (ltc2978) uninitialized stack read in ltc2978_get_id() for LT7176P
- [Medium] hwmon: (pmbus/ltc2978) IEEE754 peak values compared as LINEAR11 in ltc_get_max()
--
commit 51707b0225138ad0d3a2b0dd58f194120d060f5a
Author: Christopher de Guzman <christopher.deguzman@analog.com>
hwmon: (pmbus/ltc2978) Add support for LT7175 and LT7176P
This commit adds support for the LT7175/LT7175-1 and LT7176P/LT7176P-1 PMBus
buck regulators to the ltc2978 driver, distinguishing them via the
PMBUS_IC_DEVICE_ID string and configuring them with IEEE754 telemetry format.
> diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
> index aea7b6c93e74b..a42cdc1fe1246 100644
> --- a/drivers/hwmon/pmbus/ltc2978.c
> +++ b/drivers/hwmon/pmbus/ltc2978.c
[ ... ]
> @@ -645,6 +649,10 @@ static int ltc2978_get_id(struct i2c_client *client)
> return lt7170;
> if (!strncmp(buf, "LT7171", 6))
> return lt7171;
> + if (!strncmp(buf, "LT7175", 6))
> + return lt7175;
> + if (!strncmp(buf, "LT7176P", 7))
> + return lt7176p;
[Severity: Medium]
Can strncmp() read uninitialized stack memory in buf[6] here?
In drivers/hwmon/pmbus/ltc2978.c, ltc2978_get_id() reads PMBUS_IC_DEVICE_ID
into an uninitialized stack buffer via pmbus_read_smbus_i2c_block_data(),
which copies ret bytes without NUL-terminating buf, and then checks only
for ret < 6:
if (chip_id == LT7170_ID) {
u8 buf[I2C_SMBUS_BLOCK_MAX];
int ret;
ret = pmbus_read_smbus_i2c_block_data(client, PMBUS_IC_DEVICE_ID,
buf);
if (ret < 0)
return ret;
if (ret < 6)
return -ENODEV;
If a device returns a 6-byte PMBUS_IC_DEVICE_ID starting with "LT7176"
(where ret == 6), calling strncmp(buf, "LT7176P", 7) without checking
ret >= 7 will read buf[6] from the uninitialized stack buffer and falsely
match lt7176p if that byte happens to be 'P'.
>
> return -ENODEV;
> }
> @@ -774,6 +782,20 @@ static int ltc2978_probe(struct i2c_client *client)
> | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
> | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
> break;
> + case lt7175:
> + case lt7176p:
> + data->features |= FEAT_CLEAR_PEAKS | FEAT_NEEDS_POLLING;
> + info->read_word_data = ltc3883_read_word_data;
> + info->pages = LTC3883_NUM_PAGES;
> + info->format[PSC_VOLTAGE_IN] = ieee754;
> + info->format[PSC_VOLTAGE_OUT] = ieee754;
> + info->format[PSC_CURRENT_OUT] = ieee754;
> + info->format[PSC_TEMPERATURE] = ieee754;
> + info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
> + | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
> + | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
> + | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
> + break;
[Severity: Medium]
Will wiring info->read_word_data to ltc3883_read_word_data cause corrupted
peak readings when the sensor formats are set to ieee754?
For lt7175 and lt7176p, virtual peak reads for PMBUS_VIRT_READ_VIN_MAX,
PMBUS_VIRT_READ_IOUT_MAX, and PMBUS_VIRT_READ_TEMP_MAX go through
ltc3883_read_word_data() -> ltc3880_read_word_data() ->
ltc2978_read_word_data_common() -> ltc_get_max():
static int ltc_get_max(struct ltc2978_data *data, struct i2c_client *client,
int page, int reg, u16 *pmax)
{
int ret;
ret = ltc_read_word_data(client, page, 0xff, reg);
if (ret >= 0) {
if (lin11_to_val(ret) > lin11_to_val(*pmax))
*pmax = ret;
ret = *pmax;
}
return ret;
}
Because lin11_to_val() treats bit 10 as the sign bit of an 11-bit two's
complement mantissa, whereas in IEEE754 binary16 bit 10 is the least
significant bit of the 5-bit biased exponent, any positive IEEE754 value with
an odd biased exponent (e.g. [1, 2), [4, 8), [16, 32), [64, 128)) has bit 10
set and is decoded by lin11_to_val() as negative.
As a result, when a peak reading increases from an even biased exponent into
an odd biased exponent (such as temperature rising from 40 C to 75 C, or IOUT
rising from 2.5 A to 6.0 A), ltc_get_max() will treat the new higher reading
as negative and fail to update *pmax, or overwrite a higher odd-exponent peak
with a lower even-exponent reading.
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261020-upstream-lt7175-lt7176p-v1-0-86b9b728b95d@analog.com?part=2
next prev parent reply other threads:[~2026-10-20 12:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 11:45 [PATCH 0/3] hwmon: (pmbus/ltc2978) Add support for LT7175 and LT7176P Christopher de Guzman
2026-10-20 11:45 ` [PATCH 1/3] dt-bindings: hwmon: ltc2978: " Christopher de Guzman
2026-10-20 11:45 ` [PATCH 2/3] hwmon: (pmbus/ltc2978) " Christopher de Guzman
2026-10-20 12:01 ` sashiko-bot [this message]
2026-10-20 11:45 ` [PATCH 3/3] hwmon: ltc2978: Document LT7175 and LT7176P support Christopher de Guzman
2026-10-20 11:54 ` 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=sashiko-outbox-178914@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=christopher.deguzman@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=robh@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