RE: [PATCH V2] ARM: imx: Add missing of_node_put()
From: Anson Huang
Date: Thu Feb 13 2020 - 03:41:27 EST
Hi, Uwe
> Subject: Re: [PATCH V2] ARM: imx: Add missing of_node_put()
>
> 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.)
Make sense, please help review V3.
Thanks,
Anson