From: Jonathan Cameron <jic23@kernel.org>
To: Guilherme Ivo Bozi <guilherme.bozi@usp.br>
Cc: "Salih Erim" <salih.erim@amd.com>,
"Conall O'Griofa" <conall.ogriofa@amd.com>,
"Michal Simek" <michal.simek@amd.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/3] iio: adc: xilinx-ams: fix out-of-bounds channel lookup in event handling
Date: Tue, 12 May 2026 16:54:44 +0100 [thread overview]
Message-ID: <20260512165444.4ae39d90@jic23-huawei> (raw)
In-Reply-To: <CAJgF-xum3OQ36keRW5gCnTTbnUhsHZUzL41xKn0hjJ3GqgyOZg@mail.gmail.com>
On Tue, 12 May 2026 12:40:05 -0300
Guilherme Ivo Bozi <guilherme.bozi@usp.br> wrote:
> Hi Salih,
>
> Replies are inline.
>
> On Tue, May 12, 2026 at 11:22 AM Salih Erim <salih.erim@amd.com> wrote:
> >
> > Hi Guilherme,
> >
> > Replies are inline.
> >
> > On 4/14/2026 11:40 PM, Guilherme Ivo Bozi wrote:
> > > ams_event_to_channel() may return a pointer past the end of
> > > dev->channels when no matching scan_index is found. This can lead
> > > to invalid memory access in ams_handle_event().
> > >
> > > Add a bounds check in ams_event_to_channel() and return NULL when
> > > no channel is found. Also guard the caller to safely handle this
> > > case.
> > >
> > > Fixes: d5c70627a794 ("iio: adc: Add Xilinx AMS driver")
> > > Signed-off-by: Guilherme Ivo Bozi <guilherme.bozi@usp.br>
> > > ---
> > > drivers/iio/adc/xilinx-ams.c | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c
> > > index 124470c92529..6191cd1b29a5 100644
> > > --- a/drivers/iio/adc/xilinx-ams.c
> > > +++ b/drivers/iio/adc/xilinx-ams.c
> > > @@ -871,6 +871,9 @@ static const struct iio_chan_spec *ams_event_to_channel(struct iio_dev *dev,
> > > if (dev->channels[i].scan_index == scan_index)
> > > break;
> > >
> > > + if (i == dev->num_channels)
> > > + return NULL;
> > > +
> > The added lines use spaces for indentation instead of tabs.
> I checked both locally and the raw mbox from lore.kernel.org, and the
> indentation uses TAB characters consistently (^I in the diff).
>
> To verify, I inspected the relevant hunk using cat -A:
>
> ^I^Iif (dev->channels[i].scan_index == scan_index)
> ^I^I^Ibreak;
>
> +^Iif (i == dev->num_channels)
> +^I^Ireturn NULL;
>
> ^Ireturn &dev->channels[i];
>
> I could not observe any indentation issues locally or from the raw mbox.
FWIW they look good to me as well. Salih, I'd guess you have a local issue.
b4 (on git.kernel.org) is really handy for ensuring none of those occur!
Jonathan
>
> >
> > Salih
> >
>
> --
> Guilherme Ivo
next prev parent reply other threads:[~2026-05-12 15:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-14 22:40 [PATCH v3 0/3] iio: adc: xilinx-ams: refactor alarm handling to table-driven design Guilherme Ivo Bozi
2026-04-14 22:40 ` [PATCH v3 1/3] iio: adc: xilinx-ams: fix out-of-bounds channel lookup in event handling Guilherme Ivo Bozi
2026-05-12 14:22 ` Salih Erim
2026-05-12 15:40 ` Guilherme Ivo Bozi
2026-05-12 15:54 ` Jonathan Cameron [this message]
2026-05-12 18:05 ` Salih Erim
2026-04-14 22:40 ` [PATCH v3 2/3] iio: adc: xilinx-ams: use guard(mutex) for automatic locking Guilherme Ivo Bozi
2026-05-12 14:25 ` Salih Erim
2026-04-14 22:40 ` [PATCH v3 3/3] iio: adc: xilinx-ams: refactor alarm mapping to table-driven approach Guilherme Ivo Bozi
2026-05-12 14:34 ` Salih Erim
2026-05-12 15:46 ` Guilherme Ivo Bozi
2026-04-25 15:34 ` [PATCH v3 0/3] iio: adc: xilinx-ams: refactor alarm handling to table-driven design Jonathan Cameron
2026-05-12 11:00 ` Guilherme Ivo Bozi
2026-05-12 11:02 ` Michal Simek
2026-05-12 11:26 ` Erim, Salih
2026-05-12 14:18 ` Salih Erim
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=20260512165444.4ae39d90@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=conall.ogriofa@amd.com \
--cc=dlechner@baylibre.com \
--cc=guilherme.bozi@usp.br \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=nuno.sa@analog.com \
--cc=salih.erim@amd.com \
/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