From: Tony Lindgren <tony@atomide.com>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Liang He <windhl@126.com>,
andre.przywara@arm.com, thierry.reding@gmail.com,
jonathanh@nvidia.com, linux-arm-kernel@lists.infradead.org,
linux-omap@vger.kernel.org, linux-tegra@vger.kernel.org,
Krzysztof Kozlowski <krzk@kernel.org>
Subject: Re: [PATCH] arm/mach: Hold reference returned by of_find_xxx APIs
Date: Wed, 29 Jun 2022 11:37:38 +0300 [thread overview]
Message-ID: <YrwPUgzXgDp5djxM@atomide.com> (raw)
In-Reply-To: <YrspRE+g7QvzOvgr@shell.armlinux.org.uk>
* Russell King (Oracle) <linux@armlinux.org.uk> [220628 16:11]:
> On Tue, Jun 28, 2022 at 06:59:45AM +0300, Tony Lindgren wrote:
> > * Liang He <windhl@126.com> [220621 12:14]:
> > > diff --git a/arch/arm/mach-omap2/pmic-cpcap.c b/arch/arm/mach-omap2/pmic-cpcap.c
> > > index 668dc84fd31e..a7368d657aa8 100644
> > > --- a/arch/arm/mach-omap2/pmic-cpcap.c
> > > +++ b/arch/arm/mach-omap2/pmic-cpcap.c
> > > @@ -238,8 +238,11 @@ static struct omap_voltdm_pmic omap4_fan_iva = {
> > > int __init omap4_cpcap_init(void)
> > > {
> > > struct voltagedomain *voltdm;
> > > + struct device_node *np;
> > >
> > > - if (!of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
> > > + np = of_find_compatible_node(NULL, NULL, "motorola,cpcap");
> > > + of_node_put(np);
> > > + if (!np)
> > > return -ENODEV;
> >
> > Hmm so here you are checking for !np after of_node_put()?
>
> This is permissible, because the value of the _pointer_ is being
> checked without dereferencing the pointer. So the fact that the
> node may have been freed is actually immaterial.
OK yeah. This is several lines of code to check if something exists.
Maybe we should just add bool of_compatible_node_exists() to simplify
cases like this that does not keep the kfef.
Regards,
Tony
WARNING: multiple messages have this Message-ID (diff)
From: Tony Lindgren <tony@atomide.com>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Liang He <windhl@126.com>,
andre.przywara@arm.com, thierry.reding@gmail.com,
jonathanh@nvidia.com, linux-arm-kernel@lists.infradead.org,
linux-omap@vger.kernel.org, linux-tegra@vger.kernel.org,
Krzysztof Kozlowski <krzk@kernel.org>
Subject: Re: [PATCH] arm/mach: Hold reference returned by of_find_xxx APIs
Date: Wed, 29 Jun 2022 11:37:38 +0300 [thread overview]
Message-ID: <YrwPUgzXgDp5djxM@atomide.com> (raw)
In-Reply-To: <YrspRE+g7QvzOvgr@shell.armlinux.org.uk>
* Russell King (Oracle) <linux@armlinux.org.uk> [220628 16:11]:
> On Tue, Jun 28, 2022 at 06:59:45AM +0300, Tony Lindgren wrote:
> > * Liang He <windhl@126.com> [220621 12:14]:
> > > diff --git a/arch/arm/mach-omap2/pmic-cpcap.c b/arch/arm/mach-omap2/pmic-cpcap.c
> > > index 668dc84fd31e..a7368d657aa8 100644
> > > --- a/arch/arm/mach-omap2/pmic-cpcap.c
> > > +++ b/arch/arm/mach-omap2/pmic-cpcap.c
> > > @@ -238,8 +238,11 @@ static struct omap_voltdm_pmic omap4_fan_iva = {
> > > int __init omap4_cpcap_init(void)
> > > {
> > > struct voltagedomain *voltdm;
> > > + struct device_node *np;
> > >
> > > - if (!of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
> > > + np = of_find_compatible_node(NULL, NULL, "motorola,cpcap");
> > > + of_node_put(np);
> > > + if (!np)
> > > return -ENODEV;
> >
> > Hmm so here you are checking for !np after of_node_put()?
>
> This is permissible, because the value of the _pointer_ is being
> checked without dereferencing the pointer. So the fact that the
> node may have been freed is actually immaterial.
OK yeah. This is several lines of code to check if something exists.
Maybe we should just add bool of_compatible_node_exists() to simplify
cases like this that does not keep the kfef.
Regards,
Tony
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-06-29 8:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 9:19 [PATCH] arm/mach: Hold reference returned by of_find_xxx APIs Liang He
2022-06-21 9:19 ` Liang He
2022-06-22 8:51 ` Krzysztof Kozlowski
2022-06-22 8:51 ` Krzysztof Kozlowski
2022-06-28 3:59 ` Tony Lindgren
2022-06-28 3:59 ` Tony Lindgren
2022-06-28 4:05 ` Liang He
2022-06-28 4:05 ` Liang He
2022-06-28 16:16 ` Russell King (Oracle)
2022-06-28 16:16 ` Russell King (Oracle)
2022-06-29 8:37 ` Tony Lindgren [this message]
2022-06-29 8:37 ` Tony Lindgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YrwPUgzXgDp5djxM@atomide.com \
--to=tony@atomide.com \
--cc=andre.przywara@arm.com \
--cc=jonathanh@nvidia.com \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=thierry.reding@gmail.com \
--cc=windhl@126.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.