Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: at_hdmac: fix device leak on of_dma_xlate()

Make sure to drop the reference taken when looking up the DMA platform
device during of_dma_xlate() when releasing channel resources.

Note that commit 3832b78b3ec2 ("dmaengine: at_hdmac: add missing
put_device() call in at_dma_xlate()") fixed the leak in a couple of
error paths but the reference is still leaking on successful allocation.

Fixes: bbe89c8e3d59 ("at_hdmac: move to generic DMA binding")
Fixes: 3832b78b3ec2 ("dmaengine: at_hdmac: add missing put_device() call in at_dma_xlate()")
Cc: stable@vger.kernel.org # 3.10: 3832b78b3ec2
Cc: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20251117161258.10679-2-johan@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Johan Hovold and committed by
Vinod Koul
b9074b2d c7d436a6

+7 -2
+7 -2
drivers/dma/at_hdmac.c
··· 1765 1765 static void atc_free_chan_resources(struct dma_chan *chan) 1766 1766 { 1767 1767 struct at_dma_chan *atchan = to_at_dma_chan(chan); 1768 + struct at_dma_slave *atslave; 1768 1769 1769 1770 BUG_ON(atc_chan_is_enabled(atchan)); 1770 1771 ··· 1775 1774 /* 1776 1775 * Free atslave allocated in at_dma_xlate() 1777 1776 */ 1778 - kfree(chan->private); 1779 - chan->private = NULL; 1777 + atslave = chan->private; 1778 + if (atslave) { 1779 + put_device(atslave->dma_dev); 1780 + kfree(atslave); 1781 + chan->private = NULL; 1782 + } 1780 1783 1781 1784 dev_vdbg(chan2dev(chan), "free_chan_resources: done\n"); 1782 1785 }