From: sashiko-bot@kernel.org
To: "Matti Vaittinen" <matti.vaittinen@linux.dev>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org,
linux-hwmon@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH 6/7] hwmon: adm1275: Support ROHM BD12790
Date: Tue, 16 Jun 2026 06:59:44 +0000 [thread overview]
Message-ID: <20260616065944.95FF11F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <8ca875d21f2d9a4d53a87b47a5e6efab48266178.1781591132.git.mazziesaccount@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The driver compares the device-returned PMBUS_MFR_MODEL string using strncasecmp without verifying the returned length, leading to uninitialized stack memory reads.
- [High] Multiplication of power and current coefficients by `shunt` overflows a 32-bit unsigned integer for larger shunt resistors.
--
commit 8dff4bf5659b589eabe7fc876665de9339faae1f
Author: Matti Vaittinen <mazziesaccount@gmail.com>
hwmon: adm1275: Support ROHM BD12790
Add support for ROHM BD12790 hot-swap controller which is largely
similar to Analog Devices adm1272.
> diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c
> --- a/drivers/hwmon/pmbus/adm1275.c
> +++ b/drivers/hwmon/pmbus/adm1275.c
[ ... ]
> @@ -581,7 +606,8 @@ static int adm1275_probe(struct i2c_client *client)
> if (mid->driver_data == adm1272 || mid->driver_data == adm1273 ||
> mid->driver_data == adm1278 || mid->driver_data == adm1281 ||
> mid->driver_data == adm1293 || mid->driver_data == adm1294 ||
> - mid->driver_data == bd12780 || mid->driver_data == sq24905c)
> + mid->driver_data == bd12780 || mid->driver_data == bd12790 ||
> + mid->driver_data == sq24905c)
> config_read_fn = i2c_smbus_read_word_data;
> else
[Severity: High]
This is a pre-existing issue, but I noticed that just before this block in
adm1275_probe(), there might be an out-of-bounds stack read:
ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, block_buffer);
if (ret < 0) { ... }
for (mid = adm1275_id; mid->name[0]; mid++) {
if (!strncasecmp(mid->name, block_buffer, strlen(mid->name)))
break;
}
Does this code read uninitialized stack memory if the device returns a
string that matches a valid model name prefix, but is shorter than the valid
model name length?
Since i2c_smbus_read_block_data() reads up to 32 bytes into the uninitialized
stack array block_buffer without appending a null terminator, strncasecmp()
could read past the valid bytes returned in ret.
For example, if the device returns a shorter string like "adm12", checking
it against "adm1275" up to the length of "adm1275" will continue reading
into uninitialized stack bounds.
[ ... ]
> @@ -685,12 +722,23 @@ static int adm1275_probe(struct i2c_client *client)
> break;
> case adm1272:
> case adm1273:
> + case bd12790:
> + {
[ ... ]
[Severity: High]
This isn't a bug introduced by this patch, but looking further down in
adm1275_probe(), could the coefficient calculations for current and power
overflow a 32-bit unsigned integer?
info->m[PSC_CURRENT_OUT] =
coefficients[cindex].m * shunt / 1000;
info->m[PSC_POWER] =
coefficients[pindex].m * shunt / 1000;
If a larger shunt resistor value is provided via device tree
(e.g., 200,000 micro-ohms to measure lower currents), multiplying this by
larger coefficients like 30631 (used for ADM1293) evaluates to 6,126,200,000.
Since shunt is a u32 and the coefficient promotes to int, this operation uses
32-bit unsigned arithmetic.
Does this wrap-around the maximum 32-bit value of 4,294,967,295 and result
in drastically incorrect telemetry scaling factors?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1781591132.git.mazziesaccount@gmail.com?part=6
next prev parent reply other threads:[~2026-06-16 6:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 6:33 [PATCH 0/7] Support ROHM BD127x0 hot-swap controllers Matti Vaittinen
2026-06-16 6:35 ` [PATCH 1/7] dt-bindings: adm1275: ROHM BD12780 hot-swap controller Matti Vaittinen
2026-06-16 6:55 ` sashiko-bot
2026-06-16 6:36 ` [PATCH 2/7] doc: Add ROHM BD12780 and BD12780A Matti Vaittinen
2026-06-16 6:52 ` sashiko-bot
2026-06-16 6:36 ` [PATCH 3/7] hwmon: adm1275: Support ROHM BD12780 Matti Vaittinen
2026-06-16 6:54 ` sashiko-bot
2026-06-16 6:37 ` [PATCH 4/7] dt-bindings: adm1275: ROHM BD12790 hot-swap controller Matti Vaittinen
2026-06-16 6:53 ` sashiko-bot
2026-06-16 6:38 ` [PATCH 5/7] doc: adm1275: Add ROHM BD12790 Matti Vaittinen
2026-06-16 6:54 ` sashiko-bot
2026-06-16 6:44 ` [PATCH 6/7] hwmon: adm1275: Support " Matti Vaittinen
2026-06-16 6:59 ` sashiko-bot [this message]
2026-06-16 6:47 ` [PATCH 7/7] hwmon: adm1275: Support module auto-loading Matti Vaittinen
2026-06-16 6:59 ` 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=20260616065944.95FF11F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=matti.vaittinen@linux.dev \
--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