From: sashiko-bot@kernel.org
To: "Alexis Czezar Torreno" <alexisczezar.torreno@analog.com>
Cc: conor+dt@kernel.org, linux-hwmon@vger.kernel.org,
robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 6/6] hwmon: (pmbus/max20830): add support for max20830c and max20840c
Date: Tue, 30 Jun 2026 02:54:49 +0000 [thread overview]
Message-ID: <20260630025450.2236B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260630-dev-max20830c-v1-6-a02786bde470@analog.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing NULL check for the return value of i2c_get_match_data() leads to a potential NULL pointer dereference.
--
commit 44325aff0c44d84d978feed33af57c60c31e89f3
Author: Alexis Czezar Torreno <alexisczezar.torreno@analog.com>
hwmon: (pmbus/max20830): add support for max20830c and max20840c
This commit adds support for the MAX20830C and MAX20840C step-down DC-DC
switching regulators with PMBus interfaces. It updates the driver to handle
multiple device types by introducing chip-specific information structures
and matching data.
> diff --git a/drivers/hwmon/pmbus/max20830.c b/drivers/hwmon/pmbus/max20830.c
> index a3abd24437e8e..252c77beb243c 100644
> --- a/drivers/hwmon/pmbus/max20830.c
> +++ b/drivers/hwmon/pmbus/max20830.c
[ ... ]
> @@ -60,11 +83,14 @@ static struct pmbus_driver_info max20830_info = {
>
> static int max20830_probe(struct i2c_client *client)
> {
> + const struct max20830_chip_info *chip;
> u8 buf[I2C_SMBUS_BLOCK_MAX + 1] = {};
> struct max20830_data *data;
> struct gpio_desc *enable_gpio;
> int ret;
>
> + chip = i2c_get_match_data(client);
> +
[Severity: High]
Can this result in a NULL pointer dereference if i2c_get_match_data() returns
NULL?
If an I2C device is instantiated via sysfs using driver_override with a
device name that doesn't exist in the driver's ID tables, table matching is
bypassed and i2c_get_match_data() will return NULL.
> data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
> if (!data)
> return -ENOMEM;
[ ... ]
> if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BLOCK_DATA)) {
> - /* Reads 9 Data bytes from MAX20830 */
> ret = i2c_smbus_read_block_data(client, PMBUS_IC_DEVICE_ID, buf);
> if (ret < 0)
> return dev_err_probe(&client->dev, ret,
> "Failed to read IC_DEVICE_ID\n");
> } else {
> - /* Reads 1 length byte + 9 Data bytes from MAX20830 */
> + /* Reads 1 length byte + data bytes */
> ret = i2c_smbus_read_i2c_block_data(client, PMBUS_IC_DEVICE_ID,
> - MAX20830_IC_DEVICE_ID_LENGTH + 1,
> - buf);
> + chip->id_length + 1, buf);
The chip pointer is then dereferenced here when reading chip->id_length without
first checking if it is valid. Should there be a validation check on chip after
it is obtained from i2c_get_match_data()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630-dev-max20830c-v1-0-a02786bde470@analog.com?part=6
next prev parent reply other threads:[~2026-06-30 2:54 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 2:46 [PATCH 0/6] Add support for MAX20830C and MAX20840C step-down DC-DC switching regulator Alexis Czezar Torreno
2026-06-30 2:46 ` [PATCH 1/6] dt-bindings: hwmon: (pmbus/max20830): add enable-gpios property Alexis Czezar Torreno
2026-06-30 2:51 ` sashiko-bot
2026-06-30 7:26 ` Krzysztof Kozlowski
2026-06-30 8:07 ` Torreno, Alexis Czezar
2026-06-30 15:48 ` Guenter Roeck
2026-07-01 1:16 ` Torreno, Alexis Czezar
2026-06-30 2:46 ` [PATCH 2/6] hwmon: (pmbus/max20830): add support for enable GPIO Alexis Czezar Torreno
2026-06-30 2:53 ` sashiko-bot
2026-06-30 3:50 ` Guenter Roeck
2026-06-30 4:51 ` Guenter Roeck
2026-06-30 8:07 ` Torreno, Alexis Czezar
2026-06-30 2:46 ` [PATCH 3/6] dt-bindings: hwmon: (pmbus/max20830): add VOUT feedback resistor properties Alexis Czezar Torreno
2026-06-30 3:02 ` sashiko-bot
2026-06-30 7:39 ` Krzysztof Kozlowski
2026-06-30 2:46 ` [PATCH 4/6] hwmon: (pmbus/max20830): add VOUT feedback resistor scaling support Alexis Czezar Torreno
2026-06-30 3:00 ` sashiko-bot
2026-06-30 4:53 ` Guenter Roeck
2026-06-30 8:07 ` Torreno, Alexis Czezar
2026-06-30 15:34 ` Guenter Roeck
2026-07-01 1:16 ` Torreno, Alexis Czezar
2026-06-30 2:46 ` [PATCH 5/6] dt-bindings: hwmon: (pmbus/max20830): add max20830c and max20840c support Alexis Czezar Torreno
2026-06-30 2:56 ` sashiko-bot
2026-06-30 7:41 ` Krzysztof Kozlowski
2026-06-30 8:07 ` Torreno, Alexis Czezar
2026-06-30 15:06 ` Guenter Roeck
2026-06-30 2:46 ` [PATCH 6/6] hwmon: (pmbus/max20830): add support for max20830c and max20840c Alexis Czezar Torreno
2026-06-30 2:54 ` sashiko-bot [this message]
2026-06-30 3:43 ` Guenter Roeck
2026-06-30 8:07 ` Torreno, Alexis Czezar
2026-06-30 15:04 ` Guenter Roeck
2026-07-02 2:50 ` Torreno, Alexis Czezar
2026-07-02 4:43 ` Guenter Roeck
2026-07-02 7:28 ` Torreno, Alexis Czezar
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=20260630025450.2236B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexisczezar.torreno@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.