Re: [PATCH] soc: ti: knav_dma: Fix device node leak in of_channel_match_helper()
From: Nishanth Menon
Date: Fri Nov 20 2026 - 11:08:53 EST
On 18:11-20261110, zhaofeng2 wrote:
> From: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
>
> of_channel_match_helper() resolves the "ti,navigator-dmas" phandle
> with of_parse_phandle_with_fixed_args() to obtain the channel number,
> which takes a reference on the dma device node in args.np, but the
> reference is never dropped after the channel number has been read
> from args.args[0], so the dma node is leaked on every channel open.
>
> Drop the reference once the channel number has been retrieved. The
> phandle stored in dma_node is deliberately kept, as its ->name string
> is handed out through *dma_instance and compared against later in
> knav_dma_open_channel().
But, do we need to take care of dma_node around error paths?
>
> Fixes: 88139ed03058 ("soc: ti: add Keystone Navigator DMA support")
> Signed-off-by: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
> ---
> drivers/soc/ti/knav_dma.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c
> --- a/drivers/soc/ti/knav_dma.c
> +++ b/drivers/soc/ti/knav_dma.c
> @@ -387,6 +387,8 @@
> return -ENODEV;
> }
>
> + of_node_put(args.np);
> +
> return args.args[0];
> }
>
>
>
--
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
https://ti.com/opensource