Skip to contentSkip to conversation

dmaengine: fsldma: kill the channel tasklet on remove

PATCH In review Aldo Ariel Panzardo 1 participant 2 messages Sep 23 – Oct 24

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: fsldma: kill the channel tasklet on remove

fsl_dma_chan_remove() frees the fsldma_chan structure without first quiescing the channel's tasklet. If an IRQ fires just before the remove and schedules the tasklet, dma_do_tasklet() runs against the freed channel struct, causing a use-after-free.

Add tasklet_kill() before tearing the channel down.

Fixes d3f620b2c4fe ("fsldma: simplify IRQ probing and handling")
---
 drivers/dma/fsldma.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/fsldma.c +1 -0
index 22d62d9..0e2f848 100644
@@ -1205,6 +1205,7 @@ static int fsl_dma_chan_probe(struct fsldma_device *fdev,
 
 static void fsl_dma_chan_remove(struct fsldma_chan *chan)
 {
+	tasklet_kill(&chan->tasklet);
 	irq_dispose_mapping(chan->irq);
 	list_del(&chan->common.device_node);
 	iounmap(chan->regs);
Signature · 1 line
2.43.0
author
#1 lore raw

Hi,

Following up on this tasklet teardown fix sent September 23.

Is there any additional testing or any change needed for review? I'm happy to work on it. Please let me know if another reviewer would be better placed to look at this driver.

Thanks,
Aldo

drivers/dma/fsldma.c static int fsl_dma_chan_probe(struct fsldma_device

Quoted 20 lines · Aldo Ariel Panzardo

fsl_dma_chan_remove() frees the fsldma_chan structure without first quiescing the channel's tasklet. If an IRQ fires just before the remove and schedules the tasklet, dma_do_tasklet() runs against the freed channel struct, causing a use-after-free.

Add tasklet_kill() before tearing the channel down.

Fixes d3f620b2c4fe ("fsldma: simplify IRQ probing and handling")
---
 drivers/dma/fsldma.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/fsldma.c +0 -0
index 22d62d9..0e2f848 100644
@@ -1205,6 +1205,7 @@ static int fsl_dma_chan_probe(struct fsldma_device

*fdev,

Quoted 9 lines
drivers/dma/fsldma.c +1 -1
 static void fsl_dma_chan_remove(struct fsldma_chan *chan)
 {
+     tasklet_kill(&chan->tasklet);
      irq_dispose_mapping(chan->irq);
      list_del(&chan->common.device_node);
      iounmap(chan->regs);
--

2.43.0