Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maxime Chevallier" <maxime.chevallier@bootlin.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 2/2] iio: adc: add driver for Texas Instruments TLA2528 adc
Date: Wed, 04 Nov 2026 13:05:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-197324@kernel.org> (raw)
In-Reply-To: <20261104125726.1754980-3-maxime.chevallier@bootlin.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] iio: adc: ti-tla2528: uninitialized stack read in tla2528_read()
--

commit 533ebab68a73de725d753757faa2921e38e9ba64
Author: Maxime Chevallier <maxime.chevallier@bootlin.com>

iio: adc: add driver for Texas Instruments TLA2528 adc

This commit adds an IIO ADC driver for the Texas Instruments TLA2528 8-channel
12-bit I2C ADC, supporting direct-mode raw channel reads and scale reporting.

> diff --git a/drivers/iio/adc/ti-tla2528.c b/drivers/iio/adc/ti-tla2528.c
> new file mode 100644
> index 0000000000000..ec754ec43d7c0
> --- /dev/null
> +++ b/drivers/iio/adc/ti-tla2528.c
> @@ -0,0 +1,215 @@

[ ... ]

> +static int tla2528_read(struct tla2528 *tla2528, u8 channel, int *val)
> +{
> +	__be16 data;
> +	int ret;
> +
> +	guard(mutex)(&tla2528->lock);
> +
> +	ret = regmap_update_bits(tla2528->regmap, TLA2528_CHANNEL_SEL_ADR,
> +				 TLA2528_CHANNEL_SEL_MANUAL_CHID, channel);
> +	if (ret)
> +		return ret;
> +
> +	ret = i2c_master_recv(tla2528->client, (char *)&data, sizeof(data));
> +	if (ret < 0)
> +		return ret;
> +
> +	*val = be16_to_cpu(data) >> 4;
> +
> +	return 0;
> +}

[Severity: Medium]
As reported by Sashiko on v2 [1], in drivers/iio/adc/ti-tla2528.c, can
tla2528_read() return uninitialized stack memory from data to user-space when
tla2528_read_raw() reads a channel?

i2c_master_recv() calls i2c_transfer_buffer_flags(), which calls
i2c_transfer() for 1 message:

drivers/i2c/i2c-core-base.c:i2c_transfer_buffer_flags() {
	...
	ret = i2c_transfer(client->adapter, &msg, 1);

	/*
	 * If everything went ok (i.e. 1 msg transferred), return #bytes
	 * transferred, else error code.
	 */
	return (ret == 1) ? count : ret;
}

If the adapter's master_xfer callback returns 0 messages transferred (or fewer
than sizeof(data) bytes are received), i2c_master_recv() returns a
non-negative value other than sizeof(data) without populating data.

Since tla2528_read() only checks for ret < 0, should it also return -EIO when
ret != sizeof(data)?

[1] https://lore.kernel.org/r/20261030164705.297354-3-maxime.chevallier@bootlin.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261104125726.1754980-1-maxime.chevallier@bootlin.com?part=2

  reply	other threads:[~2026-11-04 13:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 12:57 [PATCH v3 0/2] iio: adc: add driver for Texas Instruments TLA2528 adc Maxime Chevallier
2026-11-04 12:57 ` [PATCH v3 1/2] dt-bindings: iio: adc: add Texas Instruments TLA2528 Maxime Chevallier
2026-11-04 13:58   ` Joshua Crofts
2026-11-04 12:57 ` [PATCH v3 2/2] iio: adc: add driver for Texas Instruments TLA2528 adc Maxime Chevallier
2026-11-04 13:05   ` sashiko-bot [this message]
2026-11-04 13:56   ` Joshua Crofts
2026-11-04 15:41     ` Andy Shevchenko
2026-11-04 15:45       ` Joshua Crofts
2026-11-04 18:06     ` Maxime Chevallier

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=sashiko-outbox-197324@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --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