From: Jonathan Cameron <jic23@kernel.org>
To: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
"Andy Shevchenko" <andriy.shevchenko@intel.com>
Subject: Re: [PATCH v2] iio: adc: ti_am335x_adc: Fix potential use-after-free on DMA unbind
Date: Sat, 28 Nov 2026 19:59:25 +0000 [thread overview]
Message-ID: <20261128195925.688dc921@jic23-hlaptop> (raw)
In-Reply-To: <20261124135828.2274815-1-liguangshuo@mail.sdu.edu.cn>
On Tue, 24 Nov 2026 21:58:28 +0800
Guangshuo Li <liguangshuo@mail.sdu.edu.cn> wrote:
> A channel reference does not keep the DMA provider bound. If the EDMA
> provider is unbound first, ADC removal accesses the freed channel when
> freeing its DMA buffer and releasing the channel.
>
> Link the ADC platform device to the provider so the ADC is removed first,
> including when firmware device links are disabled. The driver core drops
> the link on probe failure or ADC removal.
>
> This issue was found by our static analysis tool under development.
>
> Fixes: f438b9da75eb ("drivers: iio: ti_am335x_adc: add dma support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
From the sashiko review of patch 1 there may be other gremlins hiding
in this driver. This seems ok though.
Applied to the testing branch of iio.git. So lined up for next merge window
rather than rushing it in.
Jonathan
> ---
> Changes in v2:
> - Use dmaengine_get_provider_device() to obtain the supplier device.
>
> Backports need 61527d7e6998 ("dmaengine: add dmaengine_get_provider_device() API").
>
> drivers/iio/adc/ti_am335x_adc.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index 0c3e0e9e8364..c7f8bafe0f4a 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -546,6 +546,11 @@ static int tiadc_request_dma(struct platform_device *pdev,
> return ret;
> }
>
> + if (!device_link_add(&pdev->dev,
> + dmaengine_get_provider_device(dma->chan),
> + DL_FLAG_AUTOREMOVE_CONSUMER))
> + goto err;
> +
> /* RX buffer */
> dma->buf = dma_alloc_coherent(dmaengine_get_dma_device(dma->chan), DMA_BUFFER_SIZE,
> &dma->addr, GFP_KERNEL);
>
> base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
prev parent reply other threads:[~2026-11-28 19:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 13:58 Guangshuo Li
2026-11-28 19:59 ` Jonathan Cameron [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=20261128195925.688dc921@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=liguangshuo@mail.sdu.edu.cn \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--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
all inboxes | Powered by JetHome®