linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Liang He <windhl@126.com>,
	"mpe@ellerman.id.au" <mpe@ellerman.id.au>,
	"benh@kernel.crashing.org" <benh@kernel.crashing.org>,
	"paulus@samba.org" <paulus@samba.org>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"rppt@kernel.org" <rppt@kernel.org>,
	"wangkefeng.wang@huawei.com" <wangkefeng.wang@huawei.com>,
	"gpiccoli@igalia.com" <gpiccoli@igalia.com>,
	"aneesh.kumar@linux.ibm.com" <aneesh.kumar@linux.ibm.com>,
	"dmitry.osipenko@collabora.com" <dmitry.osipenko@collabora.com>
Cc: "linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] powerpc: kernel: Change the order of of_node_put()
Date: Sat, 18 Jun 2022 07:13:13 +0000	[thread overview]
Message-ID: <a6a5e5b3-ffd1-904b-bba1-22baff5f7b67@csgroup.eu> (raw)
In-Reply-To: <20220617112636.4041671-1-windhl@126.com>



Le 17/06/2022 à 13:26, Liang He a écrit :
> In add_pcspkr(), it is better to call of_node_put() after the
> 'if(!np)' check.

Why is it better ?



/**
  * of_node_put() - Decrement refcount of a node
  * @node:	Node to dec refcount, NULL is supported to simplify writing of
  *		callers
  */
void of_node_put(struct device_node *node)
{
	if (node)
		kobject_put(&node->kobj);
}
EXPORT_SYMBOL(of_node_put);



Christophe


> 
> Signed-off-by: Liang He <windhl@126.com>
> ---
>   arch/powerpc/kernel/setup-common.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
> index eb0077b302e2..761817d1f4db 100644
> --- a/arch/powerpc/kernel/setup-common.c
> +++ b/arch/powerpc/kernel/setup-common.c
> @@ -563,9 +563,9 @@ static __init int add_pcspkr(void)
>   	int ret;
>   
>   	np = of_find_compatible_node(NULL, NULL, "pnpPNP,100");
> -	of_node_put(np);
>   	if (!np)
>   		return -ENODEV;
> +	of_node_put(np);
>   
>   	pd = platform_device_alloc("pcspkr", -1);
>   	if (!pd)

  reply	other threads:[~2022-06-18  7:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 11:26 [PATCH] powerpc: kernel: Change the order of of_node_put() Liang He
2022-06-18  7:13 ` Christophe Leroy [this message]
2022-06-18  8:03   ` Liang He
2022-06-18  8:48     ` Christophe Leroy
2022-06-18 16:20       ` Liang He
2022-06-20  9:23       ` Liang He
2022-06-20 11:11         ` Christophe Leroy
2022-06-20 12:27           ` 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=a6a5e5b3-ffd1-904b-bba1-22baff5f7b67@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=dmitry.osipenko@collabora.com \
    --cc=gpiccoli@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=rppt@kernel.org \
    --cc=wangkefeng.wang@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).