Skip to content

Commit b9074b2

Browse files
jhovoldvinodkoul
authored andcommitted
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 3832b78 ("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: bbe89c8 ("at_hdmac: move to generic DMA binding") Fixes: 3832b78 ("dmaengine: at_hdmac: add missing put_device() call in at_dma_xlate()") Cc: stable@vger.kernel.org # 3.10: 3832b78 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>
1 parent c7d436a commit b9074b2

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

drivers/dma/at_hdmac.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,7 @@ static int atc_alloc_chan_resources(struct dma_chan *chan)
17651765
static void atc_free_chan_resources(struct dma_chan *chan)
17661766
{
17671767
struct at_dma_chan *atchan = to_at_dma_chan(chan);
1768+
struct at_dma_slave *atslave;
17681769

17691770
BUG_ON(atc_chan_is_enabled(atchan));
17701771

@@ -1774,8 +1775,12 @@ static void atc_free_chan_resources(struct dma_chan *chan)
17741775
/*
17751776
* Free atslave allocated in at_dma_xlate()
17761777
*/
1777-
kfree(chan->private);
1778-
chan->private = NULL;
1778+
atslave = chan->private;
1779+
if (atslave) {
1780+
put_device(atslave->dma_dev);
1781+
kfree(atslave);
1782+
chan->private = NULL;
1783+
}
17791784

17801785
dev_vdbg(chan2dev(chan), "free_chan_resources: done\n");
17811786
}

0 commit comments

Comments
 (0)