ARM: omap1: Fix request_irq() leak
Subsystems (3)
PATCH 1/1 ARM: omap1: Fix request_irq() leak
omap_system_dma_probe() requests one IRQ per channel with request_irq(). If an error occurs afterwards, probe returns without freeing the requested IRQs. As dma_chan is allocated with devm_kcalloc, it is freed if probe() fails. If one of the allocated IRQ is called, it dereferences dma_chan causing a use after free.
Use devm_request_irq() to make cleanup automatic.
Fixes f31cc9622d75 ("OMAP: DMA: Convert DMA library into platform driver")
Signed-off-by Thomas Fourier <[email protected]>
--- arch/arm/mach-omap1/omap-dma.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
arch/arm/mach-omap1/omap-dma.c +3 -14
@@ -800,9 +800,9 @@ static int omap_system_dma_probe(struct platform_device *pdev)if (dma_irq ==INT_DMA_LCD )continue ; - ret =request_irq (dma_irq, - omap1_dma_irq_handler,0 ,"DMA" , - (void *) (ch +1 )); + ret =devm_request_irq (&pdev->dev, dma_irq, + omap1_dma_irq_handler,0 ,"DMA" , + (void *) (ch +1 ));if (ret !=0 ) goto exit_dma_irq_fail; }
@@ -820,19 +820,8 @@ static int omap_system_dma_probe(struct platform_device *pdev)return ret; } -static void omap_system_dma_remove (struct platform_device *pdev) -{ -int dma_irq, irq_rel =0 ; - -for ( ; irq_rel < dma_chan_count; irq_rel++) { - dma_irq =platform_get_irq (pdev, irq_rel); -free_irq (dma_irq, (void *)(irq_rel +1 )); - } -} -static struct platform_driver omap_system_dma_driver = { .probe = omap_system_dma_probe, - .remove = omap_system_dma_remove, .driver = { .name ="omap_dma_system" },
Signature · 1 line
2.53.0