From: sashiko-bot@kernel.org
To: "Alexis Czezar Torreno" <alexisczezar.torreno@analog.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v2 2/2] hwmon: (pmbus/max20830) add driver for max20830
Date: Thu, 16 Apr 2026 10:56:27 +0000 [thread overview]
Message-ID: <20260416105628.7E8EAC2BCAF@smtp.kernel.org> (raw)
In-Reply-To: <20260416-dev_max20830-v2-2-2c7d676dc0bd@analog.com>
Sashiko AI review found 2 potential issue(s):
- [High] Missing validation for short reads from `i2c_smbus_read_i2c_block_data()` can lead to uninitialized stack memory access and information leak.
- [Low] Off-by-one error when null-terminating the device ID string truncates the last character of the payload.
--
commit 479738352902d3197058c3172cee31960249a6a5
Author: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
hwmon: (pmbus/max20830) add driver for max20830
This adds support for the MAX20830 step-down DC-DC switching regulator with
a PMBus interface, allowing monitoring of input/output voltages, output
current, and temperature.
> diff --git a/drivers/hwmon/pmbus/max20830.c b/drivers/hwmon/pmbus/max20830.c
> new file mode 100644
> index 0000000000000..21ea8b59150cb
> --- /dev/null
> +++ b/drivers/hwmon/pmbus/max20830.c
[ ... ]
> + ret = i2c_smbus_read_i2c_block_data(client, PMBUS_IC_DEVICE_ID,
> + I2C_SMBUS_BLOCK_MAX, buf);
> + if (ret < 0)
> + return dev_err_probe(&client->dev, ret,
> + "Failed to read IC_DEVICE_ID\n");
i2c_smbus_read_i2c_block_data() returns the number of bytes read on success.
If the I2C controller performs a short read, returning fewer bytes than
expected, buf will contain uninitialized stack memory for the remaining
bytes.
If buf[0] coincidentally contains 9, the len != 9 check below will pass. Could
this lead to uninitialized stack memory being accessed and printed by
dev_err_probe() on a mismatch? Should we verify the number of bytes read
(e.g., ret >= 10) instead of just ret < 0?
> +
> + /* First byte is the block length. */
> + len = buf[0];
> + if (len != 9)
> + return dev_err_probe(&client->dev, -ENODEV,
> + "Unexpected IC_DEVICE_ID response\n");
> +
> + buf[len] = '\0';
Since the payload of length len occupies buf[1] through buf[len], doesn't
setting buf[len] to '\0' overwrite the final byte of the device ID payload?
While this 9th byte is ignored by the 8-byte strncmp() call below, it will
cause the dev_err_probe() error log to print a truncated string. Should the
null terminator be placed at buf[len + 1] instead?
> + if (strncmp(buf + 1, "MAX20830", 8))
> + return dev_err_probe(&client->dev, -ENODEV,
> + "Unsupported device: '%s'\n", buf + 1);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260416-dev_max20830-v2-0-2c7d676dc0bd@analog.com?part=2
next prev parent reply other threads:[~2026-04-16 10:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 7:59 [PATCH v2 0/2] Add support for MAX20830 PMBUS Alexis Czezar Torreno
2026-04-16 7:59 ` [PATCH v2 1/2] dt-bindings: hwmon: pmbus: add max20830 Alexis Czezar Torreno
2026-04-16 15:51 ` Conor Dooley
2026-04-16 18:01 ` Guenter Roeck
2026-04-16 21:31 ` Conor Dooley
2026-04-17 1:04 ` Torreno, Alexis Czezar
2026-04-17 3:22 ` Guenter Roeck
2026-04-17 3:32 ` Torreno, Alexis Czezar
2026-04-16 7:59 ` [PATCH v2 2/2] hwmon: (pmbus/max20830) add driver for max20830 Alexis Czezar Torreno
2026-04-16 10:56 ` sashiko-bot [this message]
2026-04-17 1:17 ` Torreno, Alexis Czezar
2026-04-16 14:38 ` 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=20260416105628.7E8EAC2BCAF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexisczezar.torreno@analog.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=sashiko@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