Linux Input/HID development
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Fabio Estevam <festevam@gmail.com>
Cc: lee@kernel.org, maz@kernel.org, andy@kernel.org,
	jic23@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: Thu, 19 Nov 2026 10:08:04 -0600	[thread overview]
Message-ID: <av8e5Arl0INpsv8T@SMW015318> (raw)
In-Reply-To: <20261119134041.16611-2-festevam@gmail.com>

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>
> ---
> 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
>
>

  reply	other threads:[~2026-11-19 16:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 13:40 [PATCH v5 1/4] dt-bindings: mfd: mxs-lradc: Fix interrupt order Fabio Estevam
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 [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
2026-11-19 13:40 ` [PATCH v5 4/4] mfd: mxs-lradc: Convert to devm_clk_get_enabled() Fabio Estevam
2026-11-19 16:15   ` Frank Li
2026-11-19 16:07 ` [PATCH v5 1/4] dt-bindings: mfd: mxs-lradc: Fix interrupt order 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=av8e5Arl0INpsv8T@SMW015318 \
    --to=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=jic23@kernel.org \
    --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