Re: [PATCH] dmaengine: bcm2835-dma: Add missing of_dma_controller_free()

From: Tomasz Unger

Date: Wed Nov 18 2026 - 17:22:46 EST


On Wed, Nov 18, 2026 at 01:43:05PM -0600, Frank Li wrote:
> On Sun, Nov 15, 2026 at 11:15:15PM +0100, Tomasz Unger wrote:
>> @@ -1027,6 +1029,7 @@ static void bcm2835_dma_remove(struct platform_device *pdev)
>> {
>> struct bcm2835_dmadev *od = platform_get_drvdata(pdev);
>>
>> + of_dma_controller_free(pdev->dev.of_node);
>
> use devm_of_dma_controller_register() to fix this problem

Hi Frank,

Thanks for the review. I tried that, but with only the OF registration
moved to devres, the controller entry is removed after
bcm2835_dma_remove() has returned, i.e. after
dma_async_device_unregister() and bcm2835_dma_free().

In that window bcm2835_dma_xlate() can still be reached through the
node. dma_async_device_unregister() has already freed chan->local and
dropped the last device reference (dma_device_release() does
list_del_rcu(&device->global_node)), while the channels stay on
od->ddev.channels until bcm2835_dma_free(). A client requesting a
channel at that point goes through find_candidate(), dma_chan_get()
fails with -ENODEV and global_node is deleted a second time. The same
applies to the dma_async_device_register() error path in probe.

Doing it right with devres would mean converting the whole teardown:
a devm action for bcm2835_dma_free(), dmaenginem_async_device_register(),
and devm_of_dma_controller_register() last, so that the OF entry is
removed first. That is a larger change, and
devm_of_dma_controller_register() only exists since v7.1, while this
fixes a bug from the original driver and is tagged for stable.

So I would prefer to keep this patch as a minimal fix that backports
cleanly, and send the devres conversion as a separate follow-up.
Would that work for you?

Thanks,
Tomasz