From: Xin Xiong Date: Sat, 11 Sep 2021 07:05:33 +0000 (+0800) Subject: dmaengine: mmp_pdma: fix reference count leaks in mmp_pdma_probe X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=9bf9e0b44104d05b21761441227ae566c732ecb9;p=linux.git dmaengine: mmp_pdma: fix reference count leaks in mmp_pdma_probe The issue happens in an error handling path. If of_dma_controller_register() fails, the function simply prints error messages and returns error code, without decrementing the reference count of pdev->device incremented earlier by dma_async_device_register(), which may result in refcount leaks. Fix it by invoking dma_async_device_unregister() before returning the error code. Signed-off-by: Xin Xiong Signed-off-by: Xiyu Yang Signed-off-by: Xin Tan Link: https://lore.kernel.org/r/20210911070533.3114-1-xiongx18@fudan.edu.cn Signed-off-by: Vinod Koul --- diff --git a/drivers/dma/mmp_pdma.c b/drivers/dma/mmp_pdma.c index 89f1814ff27a0..a23563cd118b7 100644 --- a/drivers/dma/mmp_pdma.c +++ b/drivers/dma/mmp_pdma.c @@ -1123,6 +1123,7 @@ static int mmp_pdma_probe(struct platform_device *op) mmp_pdma_dma_xlate, pdev); if (ret < 0) { dev_err(&op->dev, "of_dma_controller_register failed\n"); + dma_async_device_unregister(&pdev->device); return ret; } }