Re: [PATCH] iio: adc: ti_am335x_adc: Fix potential use-after-free on DMA unbind

From: Andy Shevchenko

Date: Thu Nov 19 2026 - 02:01:32 EST


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