All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Liang He <windhl@126.com>
Cc: tony@atomide.com, linux-omap@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, chenmengda2009@163.com
Subject: Re: [PATCH] ARM: OMAP2+: Hold reference returned from of_find_xxx API
Date: Thu, 15 Sep 2022 12:29:58 +0100	[thread overview]
Message-ID: <YyMMttSW97iYbkfL@shell.armlinux.org.uk> (raw)
In-Reply-To: <20220915014258.3999504-1-windhl@126.com>

On Thu, Sep 15, 2022 at 09:42:58AM +0800, Liang He wrote:
> In omap4_twl_init(), we should hold the reference returned from
> of_find_compatible_node() which has increased the refcount and
> then call of_node_put() with it when done.
> 
> Fixes: ccd369455a23 ("ARM: OMAP2+: Remove bogus warnings for machines without twl PMIC")
> Signed-off-by: Liang He <windhl@126.com>
> Signed-off-by: Mengda Chen <chenmengda2009@163.com>
> ---
>  arch/arm/mach-omap2/omap_twl.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
> index d4dab041324d..07b5f17066ce 100644
> --- a/arch/arm/mach-omap2/omap_twl.c
> +++ b/arch/arm/mach-omap2/omap_twl.c
> @@ -213,11 +213,13 @@ static struct omap_voltdm_pmic omap4_core_pmic = {
>  int __init omap4_twl_init(void)
>  {
>  	struct voltagedomain *voltdm;
> +	struct device_node *np;
>  
>  	if (!cpu_is_omap44xx() ||
> -	    of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
> +	    (np = of_find_compatible_node(NULL, NULL, "motorola,cpcap"))) {
> +		of_node_put(np);

This is buggy - if cpu_is_omap44xx() is false, then np will not be
initialised. The simple solution is to initialise np to NULL.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

WARNING: multiple messages have this Message-ID (diff)
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Liang He <windhl@126.com>
Cc: tony@atomide.com, linux-omap@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, chenmengda2009@163.com
Subject: Re: [PATCH] ARM: OMAP2+: Hold reference returned from of_find_xxx API
Date: Thu, 15 Sep 2022 12:29:58 +0100	[thread overview]
Message-ID: <YyMMttSW97iYbkfL@shell.armlinux.org.uk> (raw)
In-Reply-To: <20220915014258.3999504-1-windhl@126.com>

On Thu, Sep 15, 2022 at 09:42:58AM +0800, Liang He wrote:
> In omap4_twl_init(), we should hold the reference returned from
> of_find_compatible_node() which has increased the refcount and
> then call of_node_put() with it when done.
> 
> Fixes: ccd369455a23 ("ARM: OMAP2+: Remove bogus warnings for machines without twl PMIC")
> Signed-off-by: Liang He <windhl@126.com>
> Signed-off-by: Mengda Chen <chenmengda2009@163.com>
> ---
>  arch/arm/mach-omap2/omap_twl.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
> index d4dab041324d..07b5f17066ce 100644
> --- a/arch/arm/mach-omap2/omap_twl.c
> +++ b/arch/arm/mach-omap2/omap_twl.c
> @@ -213,11 +213,13 @@ static struct omap_voltdm_pmic omap4_core_pmic = {
>  int __init omap4_twl_init(void)
>  {
>  	struct voltagedomain *voltdm;
> +	struct device_node *np;
>  
>  	if (!cpu_is_omap44xx() ||
> -	    of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
> +	    (np = of_find_compatible_node(NULL, NULL, "motorola,cpcap"))) {
> +		of_node_put(np);

This is buggy - if cpu_is_omap44xx() is false, then np will not be
initialised. The simple solution is to initialise np to NULL.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-09-15 11:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15  1:42 [PATCH] ARM: OMAP2+: Hold reference returned from of_find_xxx API Liang He
2022-09-15  1:42 ` Liang He
2022-09-15 11:29 ` Russell King (Oracle) [this message]
2022-09-15 11:29   ` Russell King (Oracle)
2022-09-15 12:41   ` Liang He
2022-09-15 12:41     ` Liang He

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=YyMMttSW97iYbkfL@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=chenmengda2009@163.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=tony@atomide.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.