Re: [PATCH] of: unittest: Fix np reference leak in of_unittest_pci_empty_dma_ranges()
From: Andrea della Porta
Date: Thu Sep 17 2026 - 12:13:24 EST
Hi Wentao,
On 13:03 Thu 17 Sep , Wentao Liang wrote:
> of_pci_dma_range_parser_init() can fail when the node lacks a dma-ranges
> property. That error path returns without dropping the reference taken
> by of_find_node_by_path(). Add the missing of_node_put().
>
> Fixes: 1a75e81baf4f ("of/unittest: Add empty dma-ranges address translation tests")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
> ---
> drivers/of/unittest.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
> index 939cbff45ab1..6bc5babddf0a 100644
> --- a/drivers/of/unittest.c
> +++ b/drivers/of/unittest.c
> @@ -1250,6 +1250,7 @@ static void __init of_unittest_pci_empty_dma_ranges(void)
>
> if (of_pci_dma_range_parser_init(&parser, np)) {
> pr_err("missing dma-ranges property\n");
> + of_node_put(np);
> return;
> }
>
> --
> 2.34.1
>
Thanks for your patch!
Reviewed-by: Andrea della Porta <andrea.porta@xxxxxxxx>