* [PATCH] iio: adc: ti_am335x_adc: Fix potential use-after-free on DMA unbind
@ 2026-11-18 14:27 Guangshuo Li
2026-11-19 7:01 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-11-18 14:27 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, stable
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>
---
drivers/iio/adc/ti_am335x_adc.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index e53c839e87ef..07d6dc7f0355 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -547,6 +547,10 @@ static int tiadc_request_dma(struct platform_device *pdev,
return ret;
}
+ if (!device_link_add(&pdev->dev, dma->chan->device->dev,
+ 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: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: adc: ti_am335x_adc: Fix potential use-after-free on DMA unbind
2026-11-18 14:27 [PATCH] iio: adc: ti_am335x_adc: Fix potential use-after-free on DMA unbind Guangshuo Li
@ 2026-11-19 7:01 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2026-11-19 7:01 UTC (permalink / raw)
To: Guangshuo Li
Cc: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel, stable
On Wed, Nov 18, 2026 at 10:27:02PM +0800, Guangshuo Li 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.
...
> + if (!device_link_add(&pdev->dev, dma->chan->device->dev,
Now we need to use helpers to access DMA devices. For backport you will need
another patch. See dmaengine_get_provider_device().
> + DL_FLAG_AUTOREMOVE_CONSUMER))
> + goto err;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-19 7:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 14:27 [PATCH] iio: adc: ti_am335x_adc: Fix potential use-after-free on DMA unbind Guangshuo Li
2026-11-19 7:01 ` Andy Shevchenko
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®