b02e0701 | 20-Jan-2023 |
Shravan Chippa <shravan.chippa@microchip.com> |
dmaengine: sf-pdma: pdma_desc memory leak fix
Commit b2cc5c465c2c ("dmaengine: sf-pdma: Add multithread support for a DMA channel") changed sf_pdma_prep_dma_memcpy() to unconditionally allocate a ne
dmaengine: sf-pdma: pdma_desc memory leak fix
Commit b2cc5c465c2c ("dmaengine: sf-pdma: Add multithread support for a DMA channel") changed sf_pdma_prep_dma_memcpy() to unconditionally allocate a new sf_pdma_desc each time it is called.
The driver previously recycled descs, by checking the in_use flag, only allocating additional descs if the existing one was in use. This logic was removed in commit b2cc5c465c2c ("dmaengine: sf-pdma: Add multithread support for a DMA channel"), but sf_pdma_free_desc() was not changed to handle the new behaviour.
As a result, each time sf_pdma_prep_dma_memcpy() is called, the previous descriptor is leaked, over time leading to memory starvation:
unreferenced object 0xffffffe008447300 (size 192): comm "irq/39-mchp_dsc", pid 343, jiffies 4294906910 (age 981.200s) hex dump (first 32 bytes): 00 00 00 ff 00 00 00 00 b8 c1 00 00 00 00 00 00 ................ 00 00 70 08 10 00 00 00 00 00 00 c0 00 00 00 00 ..p............. backtrace: [<00000000064a04f4>] kmemleak_alloc+0x1e/0x28 [<00000000018927a7>] kmem_cache_alloc+0x11e/0x178 [<000000002aea8d16>] sf_pdma_prep_dma_memcpy+0x40/0x112
Add the missing kfree() to sf_pdma_free_desc(), and remove the redundant in_use flag.
Fixes: b2cc5c465c2c ("dmaengine: sf-pdma: Add multithread support for a DMA channel") Signed-off-by: Shravan Chippa <shravan.chippa@microchip.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20230120100623.3530634-1-shravan.chippa@microchip.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
/openbmc/linux/Documentation/devicetree/bindings/dma/allwinner,sun4i-a10-dma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/allwinner,sun50i-a64-dma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/allwinner,sun6i-a31-dma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/altr,msgdma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/apple,admac.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/arm-pl08x.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/dma-controller.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/dma-router.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/fsl,edma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/ingenic,dma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/intel,ldma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/mediatek,uart-dma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/owl-dma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/qcom,bam-dma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/qcom,gpi.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/renesas,rcar-dmac.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/renesas,rz-dmac.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/renesas,rzn1-dmamux.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/renesas,usb-dmac.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/sifive,fu540-c000-pdma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/snps,dma-spear1340.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/snps,dw-axi-dmac.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/socionext,uniphier-mio-dmac.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/socionext,uniphier-xdmac.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/st,stm32-dma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/st,stm32-dmamux.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/st,stm32-mdma.yaml/openbmc/linux/Documentation/devicetree/bindings/dma/stericsson,dma40.yaml/openbmc/linux/MAINTAINERS/openbmc/linux/drivers/dma/Kconfig/openbmc/linux/drivers/dma/dmaengine.csf-pdma.csf-pdma.h/openbmc/linux/drivers/dma/xilinx/Makefile/openbmc/linux/drivers/dma/xilinx/xdma-regs.h/openbmc/linux/drivers/dma/xilinx/xdma.c/openbmc/linux/include/linux/dma/amd_xdma.h/openbmc/linux/include/linux/dmaengine.h/openbmc/linux/include/linux/platform_data/amd_xdma.h |
7d268a28 | 18-Nov-2019 |
Green Wan <green.wan@sifive.com> |
dmaengine: sf-pdma: move macro to header file
The place where the macro, SF_PDMA_REG_BASE(), is cause kernel-doc using wrong function declaration. Move it to header file.
Signed-off-by: Green Wan <
dmaengine: sf-pdma: move macro to header file
The place where the macro, SF_PDMA_REG_BASE(), is cause kernel-doc using wrong function declaration. Move it to header file.
Signed-off-by: Green Wan <green.wan@sifive.com> Link: https://lore.kernel.org/r/20191118143554.16129-2-green.wan@sifive.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
show more ...
|