[PATCH v3] powerpc/fsl_rio: add missing of_node_put() in fsl_rio_setup()

Christophe Leroy christophe.leroy at csgroup.eu
Thu Jul 6 17:13:57 AEST 2023



Le 24/11/2022 à 15:33, Yang Yingliang a écrit :
> The of node returned by of_find_compatible_node() with refcount
> decremented, of_node_put() need be called after using it to avoid
> refcount leak.

Is that patch still required ? If yes, please rebase and resend.

Thanks
Christophe

> 
> Fixes: abc3aeae3aaa ("fsl-rio: Add two ports and rapidio message units support")
> Signed-off-by: Yang Yingliang <yangyingliang at huawei.com>
> ---
> v2 -> v3:
>    drop of_node_put() in loop for_each_child_of_node(), it's not needed.
> 
> v1 -> v2:
>    Add fix tag.
> 
> v1 patch link:
>    https://lore.kernel.org/lkml/20220615032137.1878219-1-yangyingliang@huawei.com/
> ---
>   arch/powerpc/sysdev/fsl_rio.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
> index c8f044d62fe2..1ad962d3060e 100644
> --- a/arch/powerpc/sysdev/fsl_rio.c
> +++ b/arch/powerpc/sysdev/fsl_rio.c
> @@ -550,12 +550,13 @@ int fsl_rio_setup(struct platform_device *dev)
>   	if (!dt_range) {
>   		pr_err("%pOF: unable to find 'reg' property\n",
>   			np);
>   		rc = -ENOMEM;
>   		goto err_pw;
>   	}
> +	of_node_put(np);
>   	range_start = of_read_number(dt_range, aw);
>   	dbell->dbell_regs = (struct rio_dbell_regs *)(rmu_regs_win +
>   				(u32)range_start);
>   
>   	/*set up port write node*/
>   	np = of_find_compatible_node(NULL, NULL, "fsl,srio-port-write-unit");
> @@ -578,12 +579,13 @@ int fsl_rio_setup(struct platform_device *dev)
>   	if (!dt_range) {
>   		pr_err("%pOF: unable to find 'reg' property\n",
>   			np);
>   		rc = -ENOMEM;
>   		goto err;
>   	}
> +	of_node_put(np);
>   	range_start = of_read_number(dt_range, aw);
>   	pw->pw_regs = (struct rio_pw_regs *)(rmu_regs_win + (u32)range_start);
>   
>   	/*set up ports node*/
>   	for_each_child_of_node(dev->dev.of_node, np) {
>   		port_index = of_get_property(np, "cell-index", NULL);
> @@ -760,12 +762,13 @@ int fsl_rio_setup(struct platform_device *dev)
>   err_pw:
>   	kfree(dbell);
>   	dbell = NULL;
>   err_dbell:
>   	iounmap(rmu_regs_win);
>   	rmu_regs_win = NULL;
> +	of_node_put(np);
>   err_rmu:
>   	kfree(ops);
>   err_ops:
>   	iounmap(rio_regs_win);
>   	rio_regs_win = NULL;
>   err_rio_regs:


More information about the Linuxppc-dev mailing list