From: sashiko-bot@kernel.org
To: "Michal Piekos" <michal.piekos@mmpsystems.pl>
Cc: linux-sunxi@lists.linux.dev
Subject: Re: [PATCH] iio: adc: sun20i-gpadc: support non-contiguous channel lookups
Date: Thu, 14 May 2026 03:54:08 +0000 [thread overview]
Message-ID: <20260514035408.A9AE9C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260513-fix-sunxi-gpadc-sparse-channels-v1-1-6c21e290bcee@mmpsystems.pl>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing bounds check on `iiospec->nargs` leads to uninitialized stack memory read
--
commit b20d529d5a2f9f0071b7ae62b25da6250c765297
Author: Michal Piekos <michal.piekos@mmpsystems.pl>
iio: adc: sun20i-gpadc: support non-contiguous channel lookups
This commit adds a fwnode_xlate callback to map a device tree phandle
argument to the registered channel. This allows the driver to support
non-contiguous channel lookups for consumers like iio-hwmon.
> diff --git a/drivers/iio/adc/sun20i-gpadc-iio.c b/drivers/iio/adc/sun20i-gpadc-iio.c
> index 861c14da75add..95f34a3521583 100644
> --- a/drivers/iio/adc/sun20i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun20i-gpadc-iio.c
[ ... ]
> +static int sun20i_gpadc_fwnode_xlate(struct iio_dev *indio_dev,
> + const struct fwnode_reference_args *iiospec)
> +{
> + int i;
> +
> + for (i = 0; i < indio_dev->num_channels; i++)
> + if (indio_dev->channels[i].channel == iiospec->args[0])
Could this read uninitialized stack memory if the consumer requests a channel
with 0 arguments?
In the IIO core, __fwnode_iio_channel_get() allocates the iiospec structure
on the stack without zero-initializing it. While the Device Tree backend
zero-initializes unused arguments, other backends like Software Nodes
might not.
If iiospec->nargs is 0, this comparison could use a garbage value from the
stack, leading to unpredictable channel selection or probe failure.
Should we verify if (!iiospec->nargs) before accessing iiospec->args[0]?
> + return i;
> +
> + return -EINVAL;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260513-fix-sunxi-gpadc-sparse-channels-v1-1-6c21e290bcee@mmpsystems.pl?part=1
prev parent reply other threads:[~2026-05-14 3:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 9:51 [PATCH] iio: adc: sun20i-gpadc: support non-contiguous channel lookups Michal Piekos
2026-05-13 10:53 ` Andy Shevchenko
2026-05-13 14:10 ` Jonathan Cameron
2026-05-14 3:54 ` sashiko-bot [this message]
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=20260514035408.A9AE9C2BCB7@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=michal.piekos@mmpsystems.pl \
--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.