ASoC: fsl_asrc_dma: Fix dma_chan leak when config DMA channel failed
authorXiyu Yang <xiyuyang19@fudan.edu.cn>
Mon, 25 May 2020 14:12:46 +0000 (22:12 +0800)
committerSasha Levin <sashal@kernel.org>
Tue, 30 Jun 2020 19:38:28 +0000 (15:38 -0400)
commitaa332872c7c9bb1884a4a60582d2b3986ba5df4d
tree8b0a9f4ddecad6544e74878ea7c4f8916679adad
parentae7a9734da91c3fd1405f3ae74a45be5f5140631
ASoC: fsl_asrc_dma: Fix dma_chan leak when config DMA channel failed

[ Upstream commit 36124fb19f1ae68a500cd76a76d40c6e81bee346 ]

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 <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Link: https://lore.kernel.org/r/1590415966-52416-1-git-send-email-xiyuyang19@fudan.edu.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/fsl/fsl_asrc_dma.c