]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
ASoC: davinci-mcasp: Fix dma_chan refcnt leak when getting dma type
authorXiyu Yang <xiyuyang19@fudan.edu.cn>
Sat, 25 Apr 2020 12:48:35 +0000 (20:48 +0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Sat, 8 Aug 2020 05:53:12 +0000 (01:53 -0400)
commit9cdfb6713f2f8c2771081c621e49f292e52b4953
treed5f3998825fd8c6b5b13e8ad41f3b4c6b320abf1
parent2996da12f08ac93361142b5f156ce12a377d4137
ASoC: davinci-mcasp: Fix dma_chan refcnt leak when getting dma type

BugLink: https://bugs.launchpad.net/bugs/1885322
[ Upstream commit a697ae6ea56e23397341b027098c1b11d9ab13da ]

davinci_mcasp_get_dma_type() invokes dma_request_chan(), which returns a
reference of the specified dma_chan object to "chan" with increased
refcnt.

When davinci_mcasp_get_dma_type() returns, local variable "chan" becomes
invalid, so the refcount should be decreased to keep refcount balanced.

The reference counting issue happens in one exception handling path of
davinci_mcasp_get_dma_type(). When chan device is NULL, the function
forgets to decrease the refcnt increased by dma_request_chan(), causing
a refcnt leak.

Fix this issue by calling dma_release_channel() when chan device is
NULL.

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/1587818916-38730-1-git-send-email-xiyuyang19@fudan.edu.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
sound/soc/ti/davinci-mcasp.c