All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Luna Hart" <lhart.opensource@witekio.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org,
	linux-hwmon@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH 2/2] hwmon: (tps38900x) Add driver for TI TPS389004/TPS389006/TPS389008
Date: Tue, 29 Sep 2026 23:14:44 +0000	[thread overview]
Message-ID: <20260929231444.BB1C91F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260929-lhart-dev-tps38900x-v1-2-7045c5894152@witekio.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] hwmon: undefined behavior in GENMASK() due to unchecked i2c_get_match_data()
--

commit 5632ba367123600a6ee38c612901f594c35ee0df
Author: Luna Hart <lhart.opensource@witekio.com>

hwmon: (tps38900x) Add driver for TI TPS389004/TPS389006/TPS389008

This commit adds support for the TI TPS389004/TPS389006/TPS389008 I2C
voltage supervisors and monitors. It allows enabling ADC monitoring and
reading back the measured voltage in millivolts via sysfs.

> diff --git a/drivers/hwmon/tps38900x.c b/drivers/hwmon/tps38900x.c
> index 0000000000000..659d61b1cb55c 100644
> --- /dev/null
> +++ b/drivers/hwmon/tps38900x.c
[ ... ]
> +static int tps38900x_parse_dt_channels(struct device *dev,
> +				       struct tps38900x_data *priv)
> +{
[ ... ]
> +	// When no channels are explicitly described in the DT, expose all of them.
> +	if (!priv->channel_present)
> +		priv->channel_present = GENMASK(priv->num_channels - 1, 0);

[Severity: Medium]
Could this result in undefined behavior in tps38900x_parse_dt_channels()
in drivers/hwmon/tps38900x.c? If the driver is bound via sysfs
driver_override using an I2C device name not present in the driver's ID
table, num_channels would be 0. This evaluates to GENMASK(-1, 0), which
performs a bitwise shift by BITS_PER_LONG bits.

> +
> +	return 0;
> +}
> +
> +static int tps38900x_probe(struct i2c_client *client)
> +{
> +	struct device *dev = &client->dev;
> +	struct tps38900x_data *priv;
> +	struct device *hwmon_dev;
> +	int ret;
> +
> +	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
> +		return -ENODEV;
> +
> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> +	if (!priv)
> +		return -ENOMEM;
> +
> +	priv->num_channels = (uintptr_t)i2c_get_match_data(client);

[Severity: Medium]
Does this code in tps38900x_probe() in drivers/hwmon/tps38900x.c allow 0 to
be stored as the number of channels? If i2c_get_match_data() returns NULL
when a user binds the driver via sysfs driver_override, num_channels becomes
0 without being checked.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260929-lhart-dev-tps38900x-v1-0-7045c5894152@witekio.com?part=2

  reply	other threads:[~2026-09-29 23:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 23:04 [PATCH 0/2] hwmon: Add support for TI TPS389004/TPS389006/TPS389008 Luna Hart via B4 Relay
2026-09-29 23:04 ` Luna Hart
2026-09-29 23:04 ` [PATCH 1/2] dt-bindings: hwmon: Add " Luna Hart via B4 Relay
2026-09-29 23:04   ` Luna Hart
2026-09-29 23:17   ` sashiko-bot
2026-09-30 23:28     ` Luna HART
2026-10-01  8:17       ` Krzysztof Kozlowski
2026-10-01  8:17   ` Krzysztof Kozlowski
2026-10-02 23:57     ` Luna Hart
2026-09-29 23:04 ` [PATCH 2/2] hwmon: (tps38900x) Add driver for " Luna Hart via B4 Relay
2026-09-29 23:04   ` Luna Hart
2026-09-29 23:14   ` sashiko-bot [this message]
2026-10-01  8:19   ` Krzysztof Kozlowski
2026-10-03  0:13     ` Luna Hart
2026-10-12 10:57   ` Uwe Kleine-König

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=20260929231444.BB1C91F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lhart.opensource@witekio.com \
    --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.