Re: [PATCH V2] ARM: imx: Add missing of_node_put()

From: Uwe Kleine-König
Date: Thu Feb 13 2020 - 03:18:58 EST


On Thu, Feb 13, 2020 at 02:20:54PM +0800, Anson Huang wrote:
> After finishing using device node got from of_find_compatible_node(),
> of_node_put() needs to be called.
>
> Signed-off-by: Anson Huang <Anson.Huang@xxxxxxx>
> ---
> Changes since V1:
> - correct some of_node_put() place to make sure it is safe to be put.
> ---
> arch/arm/mach-imx/anatop.c | 3 +++
> arch/arm/mach-imx/gpc.c | 1 +
> arch/arm/mach-imx/platsmp.c | 1 +
> arch/arm/mach-imx/pm-imx6.c | 2 ++
> arch/arm/mach-imx/pm-imx7ulp.c | 1 +
> 5 files changed, 8 insertions(+)
>
> diff --git a/arch/arm/mach-imx/anatop.c b/arch/arm/mach-imx/anatop.c
> index 8fb68c0..5985731 100644
> --- a/arch/arm/mach-imx/anatop.c
> +++ b/arch/arm/mach-imx/anatop.c
> @@ -135,6 +135,7 @@ void __init imx_init_revision_from_anatop(void)
> void __iomem *src_base;
> u32 sbmr2;
>
> + of_node_put(np);
> np = of_find_compatible_node(NULL, NULL,
> "fsl,imx6ul-src");
> src_base = of_iomap(np, 0);
> @@ -152,6 +153,8 @@ void __init imx_init_revision_from_anatop(void)
>
> mxc_set_cpu_type(digprog >> 16 & 0xff);
> imx_set_soc_revision(revision);
> +
> + of_node_put(np);
> }

It would be a bit more natural here IMHO to introduce a second struct
device_node * variable for the fsl,imx6ul-src device. Then each
of_node_put would belong to exactly one of_find_compatible_node().
(Now the of_node_put() in line 157 frees the fsl,imx6ul-src on i.MX6ULL
and fsl,imx6q-anatop on the others.)

The other hunks look fine.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |