Re: [PATCH 2/2] dmaengine: idma64: Kill the channel tasklets in remove again

From: Andy Shevchenko

Date: Mon Nov 23 2026 - 04:47:42 EST


On Mon, Nov 23, 2026 at 12:53:07AM +0000, Suyuan Wang via B4 Relay wrote:
>
> idma64_remove() frees the IRQ and then kills the channel tasklets, as
> the comment there says, so that no tasklet scheduled by the interrupt
> runs after removal:
>
> for (i = 0; i < idma64->dma.chancnt; i++) {
> ...
> tasklet_kill(&idma64c->vchan.task);
> }
>
> Since commit e81274cd6b52 ("dmaengine: add support to dynamic
> register/unregister of channels"), dma_async_device_unregister()
> unregisters each channel and decrements dma.chancnt for it, so the
> count is 0 when this loop runs and no tasklet is killed. A tasklet
> scheduled by an interrupt can then run after the devm-allocated idma64
> and its channels have been freed.
>
> Read the channel count before unregistering the device.
>
> Found with a static analysis tool and checked by hand.

Acked-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>

...

> + /* dma_async_device_unregister() decrements dma.chancnt to 0 */
> + unsigned short nr_chan = idma64->dma.chancnt;

Which makes me think that we need to draw a line between private and
non-private members in the respective DMA data types. With this field
it's probably better to mark it with __private, or add another one
with that annotation and use it internally in DMAengine core.

--
With Best Regards,
Andy Shevchenko