Commit ec3eeb34 authored by Richard Genoud's avatar Richard Genoud Committed by Greg Kroah-Hartman

dmaengine: at_hdmac: fix memory leak in at_dma_xlate()

commit 98f5f932254b88ce828bc8e4d1642d14e5854caa upstream.

The leak was found when opening/closing a serial port a great number of
time, increasing kmalloc-32 in slabinfo.

Each time the port was opened, dma_request_slave_channel() was called.
Then, in at_dma_xlate(), atslave was allocated with devm_kzalloc() and
never freed. (Well, it was free at module unload, but that's not what we
So, here, kzalloc is more suited for the job since it has to be freed in

Fixes: bbe89c8e ("at_hdmac: move to generic DMA binding")
Reported-by: default avatarMario Forner <>
Suggested-by: default avatarAlexandre Belloni <>
Acked-by: default avatarAlexandre Belloni <>
Acked-by: default avatarLudovic Desroches <>
Signed-off-by: default avatarRichard Genoud <>
Signed-off-by: default avatarVinod Koul <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 89ed5b72
......@@ -1781,6 +1781,12 @@ static void atc_free_chan_resources(struct dma_chan *chan)
atchan->descs_allocated = 0;
atchan->status = 0;
* Free atslave allocated in at_dma_xlate()
chan->private = NULL;
dev_vdbg(chan2dev(chan), "free_chan_resources: done\n");
......@@ -1815,7 +1821,7 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
dma_cap_set(DMA_SLAVE, mask);
atslave = devm_kzalloc(&dmac_pdev->dev, sizeof(*atslave), GFP_KERNEL);
atslave = kzalloc(sizeof(*atslave), GFP_KERNEL);
if (!atslave)
return NULL;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment