Re: [PATCH v1 2/6] dmaengine: switchtec-dma: fix resource leak in alloc_chan_resources
[email protected] Mon, 27 Jul 2026 18:21:30 +0000
| Newsgroups | org.kernel.vger.dmaengine,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <[email protected]> |
> switchtec_dma_alloc_chan_resources() returns directly on any later > failure, without ever freeing the descriptor rings and coherent DMA > memory it just allocated. The dmaengine core does not call > device_free_chan_resources() when device_alloc_chan_resources() fails, > so the driver has to unwind its own partial state. > > The device-removed check also runs after ring_active and > comp_ring_active have already been set true, so a failure there left > the channel marked active despite alloc_chan_resources() reporting > failure. > > Add an error-unwind path that disables the channel and frees the > descriptor rings on every failure after allocation. ring_active and > comp_ring_active are cleared under the same locks > switchtec_dma_free_chan_resources() already uses, since the completion > tasklet checks comp_ring_active under complete_lock before touching > the completion ring, and a stale IRQ can still be in flight when this > unwind path runs. > > Reported-by: Sashiko <[email protected]> > Link: https://lore.kernel.org/dmaengine/[email protected]/T/#u > Fixes: 30eba9df76ad ("dmaengine: switchtec-dma: Implement hardware initialization and cleanup") > Signed-off-by: Logan Gunthorpe <[email protected]> Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=2