From: Jonathan Cameron <jic23@kernel.org>
To: Frank Li <Frank.li@oss.nxp.com>
Cc: Fabio Estevam <festevam@gmail.com>,
lee@kernel.org, maz@kernel.org, andy@kernel.org,
dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
mfd@lists.linux.dev, linux-iio@vger.kernel.org, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, crofts@kernel.org,
devicetree@vger.kernel.org, imx@lists.linux.dev,
stable@vger.kernel.org
Subject: Re: [PATCH v5 2/4] iio: adc: mxs-lradc: Fix trigger use-after-free on removal
Date: Sat, 21 Nov 2026 23:20:02 +0000 [thread overview]
Message-ID: <20261121232002.24cd9970@jic23-hlaptop> (raw)
In-Reply-To: <av8e5Arl0INpsv8T@SMW015318>
On Thu, 19 Nov 2026 10:08:04 -0600
Frank Li <Frank.li@oss.nxp.com> wrote:
> On Thu, Nov 19, 2026 at 10:40:39AM -0300, Fabio Estevam wrote:
> > The LRADC trigger is devm-allocated against the IIO device, but it is
> > manually unregistered after iio_device_unregister(). The latter deletes
> > the IIO device and releases its managed resources, freeing the trigger
> > before mxs_lradc_adc_trigger_remove() accesses it.
> >
> > Since commit 699fb50d9903 ("drivers: base: Free devm resources when
> > unregistering a device"), device_del() releases managed resources.
> > Consequently, iio_device_unregister() drops the trigger's allocation
> > reference before the driver unregisters it.
> >
> > On an i.MX28 EVK with KASAN enabled, unbinding the LRADC parent with:
> >
> > echo 80050000.lradc > /sys/bus/platform/drivers/mxs-lradc/unbind
> >
> > reports a slab-use-after-free in device_release_driver_internal().
> >
> > Allocate the managed trigger against the platform device instead. This
> > matches the trigger device's parent and keeps the allocation alive until
> > the platform driver's remove callback has unregistered the trigger.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: 699fb50d9903 ("drivers: base: Free devm resources when unregistering a device")
> > Signed-off-by: Fabio Estevam <festevam@gmail.com>
> > Reviewed-by: Joshua Crofts <crofts@kernel.org>
>
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
Applied 1 and 2 to the fixes-togreg branch of iio.git.
I guess I need to find time to do a sweep for any more of these
hiding.
Thanks,
Jonathan
> > ---
> > Changes since v4:
> > - None. Only collected Joshua's tag.
> >
> > drivers/iio/adc/mxs-lradc-adc.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c
> > index dda5182a5076..64dd3a9995ff 100644
> > --- a/drivers/iio/adc/mxs-lradc-adc.c
> > +++ b/drivers/iio/adc/mxs-lradc-adc.c
> > @@ -454,7 +454,7 @@ static int mxs_lradc_adc_trigger_init(struct iio_dev *iio)
> > struct iio_trigger *trig;
> > struct mxs_lradc_adc *adc = iio_priv(iio);
> >
> > - trig = devm_iio_trigger_alloc(&iio->dev, "%s-dev%i", iio->name,
> > + trig = devm_iio_trigger_alloc(adc->dev, "%s-dev%i", iio->name,
> > iio_device_id(iio));
> > if (!trig)
> > return -ENOMEM;
> > --
> > 2.43.0
> >
> >
next prev parent reply other threads:[~2026-11-21 23:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261119134041.16611-1-festevam@gmail.com>
2026-11-19 13:40 ` [PATCH v5 2/4] iio: adc: mxs-lradc: Fix trigger use-after-free on removal Fabio Estevam
2026-11-19 16:08 ` Frank Li
2026-11-21 23:20 ` Jonathan Cameron [this message]
2026-11-19 13:40 ` [PATCH v5 3/4] mfd: mxs-lradc: Pass parent IRQs to child drivers Fabio Estevam
2026-11-19 16:14 ` Frank Li
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=20261121232002.24cd9970@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=Frank.li@oss.nxp.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=crofts@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=maz@kernel.org \
--cc=mfd@lists.linux.dev \
--cc=robh@kernel.org \
--cc=stable@vger.kernel.org \
/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