[PATCH v2] powerpc/fsl_rio: add missing of_node_put() in fsl_rio_setup()
Christophe Leroy
christophe.leroy at csgroup.eu
Thu Nov 3 00:45:44 AEDT 2022
Le 29/10/2022 à 14:26, Yang Yingliang a écrit :
> The of node returned by of_find_compatible_node() or for_each_child_of_node()
> with refcount decremented, of_node_put() need be called after using it to avoid
> refcount leak.
Is that necessary to do of_node_put() so often ? Can't it be done
exclusively on the error exit path ?
>
> Fixes: abc3aeae3aaa ("fsl-rio: Add two ports and rapidio message units support")
> Signed-off-by: Yang Yingliang <yangyingliang at huawei.com>
> ---
> 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 | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
> index c8f044d62fe2..1b0be4931f18 100644
> --- a/arch/powerpc/sysdev/fsl_rio.c
> +++ b/arch/powerpc/sysdev/fsl_rio.c
> @@ -553,6 +553,7 @@ int fsl_rio_setup(struct platform_device *dev)
> 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);
> @@ -581,6 +582,7 @@ int fsl_rio_setup(struct platform_device *dev)
> 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);
>
> @@ -590,6 +592,7 @@ int fsl_rio_setup(struct platform_device *dev)
> if (!port_index) {
> dev_err(&dev->dev, "Can't get %pOF property 'cell-index'\n",
> np);
> + of_node_put(np);
> continue;
> }
>
> @@ -597,6 +600,7 @@ int fsl_rio_setup(struct platform_device *dev)
> if (!dt_range) {
> dev_err(&dev->dev, "Can't get %pOF property 'ranges'\n",
> np);
> + of_node_put(np);
> continue;
> }
>
> @@ -619,6 +623,7 @@ int fsl_rio_setup(struct platform_device *dev)
>
> dev_info(&dev->dev, "%pOF: LAW start 0x%016llx, size 0x%016llx.\n",
> np, range_start, range_size);
> + of_node_put(np);
>
> port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
> if (!port)
> @@ -763,6 +768,7 @@ int fsl_rio_setup(struct platform_device *dev)
> err_dbell:
> iounmap(rmu_regs_win);
> rmu_regs_win = NULL;
> + of_node_put(np);
> err_rmu:
> kfree(ops);
> err_ops:
More information about the Linuxppc-dev
mailing list