public inbox for linux-hwmon@vger.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexis Czezar Torreno" <alexisczezar.torreno@analog.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 2/2] hwmon: (pmbus/max20830) add driver for max20830
Date: Tue, 14 Apr 2026 04:56:46 +0000	[thread overview]
Message-ID: <20260414045647.4AACCC19425@smtp.kernel.org> (raw)
In-Reply-To: <20260414-dev_max20830-v1-2-210d3f82c571@analog.com>

Sashiko AI review found 3 potential issue(s):
- [Medium] The driver incorrectly uses `i2c_smbus_read_i2c_block_data` instead of `i2c_smbus_read_block_data`, violating the protocol and logging an untrusted binary buffer.
- [Low] The MODULE_IMPORT_NS macro uses an unquoted identifier, resulting in a build failure.
- [Low] The sysfs attribute `in2_alarm` is created but not documented.
--

commit 62ed9b8ac37c74adac303a0ebaea8df41fde6a85
Author: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>

hwmon: (pmbus/max20830) add driver for max20830

This commit adds support for the Analog Devices MAX20830 step-down DC-DC
switching regulator. It provides a PMBus client driver to monitor input and
output voltages, output current, and temperature.

> diff --git a/Documentation/hwmon/max20830.rst b/Documentation/hwmon/max20830.rst
> new file mode 100644
> index 0000000000000..b9dffb7605978
> --- /dev/null
> +++ b/Documentation/hwmon/max20830.rst
[ ... ]
> +================= ========================================
> +in1_label         "vin"
> +in1_input         Measured input voltage
> +in1_alarm         Input voltage alarm
> +in2_label         "vout1"
> +in2_input         Measured output voltage

This isn't a bug, but since the driver configuration enables
PMBUS_HAVE_STATUS_VOUT, it will expose the in2_alarm attribute. Should
in2_alarm be documented here alongside the other alarms?

> +curr1_label       "iout1"
> +curr1_input       Measured output current
> +curr1_alarm       Output current alarm
> +temp1_input       Measured temperature
> +temp1_alarm       Chip temperature alarm
> +================= ========================================

> diff --git a/drivers/hwmon/pmbus/max20830.c b/drivers/hwmon/pmbus/max20830.c
> new file mode 100644
> index 0000000000000..bcf60fd948e34
> --- /dev/null
> +++ b/drivers/hwmon/pmbus/max20830.c
[ ... ]
> +static int max20830_probe(struct i2c_client *client)
> +{
> +	u8 buf[I2C_SMBUS_BLOCK_MAX + 1];
> +	int ret;
> +
> +	if (!i2c_check_functionality(client->adapter,
> +				     I2C_FUNC_SMBUS_READ_I2C_BLOCK))
> +		return -ENODEV;
> +
> +	ret = i2c_smbus_read_i2c_block_data(client, PMBUS_IC_DEVICE_ID,
> +					    I2C_SMBUS_BLOCK_MAX, buf);

Should this use i2c_smbus_read_block_data() instead?

PMBus IC_DEVICE_ID is an SMBus Block Read command, which natively returns a
length byte followed by the data. Using the I2C block read API with a
hardcoded length of 32 forces an over-read and captures the raw SMBus length
byte in buf[0].

> +	if (ret < 0)
> +		return dev_err_probe(&client->dev, ret,
> +				     "Failed to read IC_DEVICE_ID\n");
> +
> +	buf[ret] = '\0';
> +	if (ret < 9 || strncmp(buf + 1, "MAX20830", 8))
> +		return dev_err_probe(&client->dev, -ENODEV,
> +				     "Unsupported device: '%s'\n", buf);

If the device is unsupported, will logging the buffer via %s print unprintable
characters?

Since buf[0] contains the raw length byte from the block read, this could
inject control characters and trailing binary padding into the kernel log.

[ ... ]
> +MODULE_AUTHOR("Alexis Czezar Torreno <alexisczezar.torreno@analog.com>");
> +MODULE_DESCRIPTION("PMBus driver for Analog Devices MAX20830");
> +MODULE_LICENSE("GPL");
> +MODULE_IMPORT_NS(PMBUS);

Will this cause a build failure?

The MODULE_IMPORT_NS macro expects a string literal. Should PMBUS be enclosed
in quotes, like MODULE_IMPORT_NS("PMBUS")?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260414-dev_max20830-v1-0-210d3f82c571@analog.com?part=2

  reply	other threads:[~2026-04-14  4:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14  4:28 [PATCH 0/2] Add support for MAX20830 PMBUS Alexis Czezar Torreno
2026-04-14  4:28 ` [PATCH 1/2] dt-bindings: hwmon: pmbus: add max20830 Alexis Czezar Torreno
2026-04-14  4:38   ` sashiko-bot
2026-04-14  4:28 ` [PATCH 2/2] hwmon: (pmbus/max20830) add driver for max20830 Alexis Czezar Torreno
2026-04-14  4:56   ` sashiko-bot [this message]
2026-04-14 14:54     ` 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=20260414045647.4AACCC19425@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