[PATCH] dmaengine: at_hdmac: fix memory leak in atc_prep_slave_sg

Frank Li Frank.li at oss.nxp.com
Wed Sep 30 13:43:30 PDT 2026


On Wed, Jul 22, 2026 at 10:04:02PM -0700, Rosen Penev wrote:
> The default case in the direction switch returns NULL without freeing
> the descriptor allocated earlier via kzalloc_flex(). Add the missing
> kfree(desc) before returning.
>
> Fixes: 808347f6a317 ("dmaengine: at_hdmac: add DMA slave transfers")
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <rosenp at gmail.com>
> ---

Reviewed-by: Frank Li <Frank.Li at nxp.com>

>  drivers/dma/at_hdmac.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
> index f9c336630fa2..c06f70dbc4c5 100644
> --- a/drivers/dma/at_hdmac.c
> +++ b/drivers/dma/at_hdmac.c
> @@ -1381,6 +1381,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
>  		}
>  		break;
>  	default:
> +		kfree(desc);
>  		return NULL;
>  	}
>
> --
> 2.55.0
>



More information about the linux-arm-kernel mailing list