From: Xiyu Yang Date: Mon, 25 May 2020 14:12:46 +0000 (+0800) Subject: ASoC: fsl_asrc_dma: Fix dma_chan leak when config DMA channel failed X-Git-Tag: v5.15~2585^2~131^2~37 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=36124fb19f1ae68a500cd76a76d40c6e81bee346;p=platform%2Fkernel%2Flinux-starfive.git ASoC: fsl_asrc_dma: Fix dma_chan leak when config DMA channel failed fsl_asrc_dma_hw_params() invokes dma_request_channel() or fsl_asrc_get_dma_channel(), which returns a reference of the specified dma_chan object to "pair->dma_chan[dir]" with increased refcnt. The reference counting issue happens in one exception handling path of fsl_asrc_dma_hw_params(). When config DMA channel failed for Back-End, the function forgets to decrease the refcnt increased by dma_request_channel() or fsl_asrc_get_dma_channel(), causing a refcnt leak. Fix this issue by calling dma_release_channel() when config DMA channel failed. Signed-off-by: Xiyu Yang Signed-off-by: Xin Tan Link: https://lore.kernel.org/r/1590415966-52416-1-git-send-email-xiyuyang19@fudan.edu.cn Signed-off-by: Mark Brown --- diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c index e5d1b21..d6a3fc5 100644 --- a/sound/soc/fsl/fsl_asrc_dma.c +++ b/sound/soc/fsl/fsl_asrc_dma.c @@ -261,6 +261,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, ret = dmaengine_slave_config(pair->dma_chan[dir], &config_be); if (ret) { dev_err(dev, "failed to config DMA channel for Back-End\n"); + dma_release_channel(pair->dma_chan[dir]); return ret; }