From: 和亮 <windhl@126.com>
To: "Rob Herring" <robh@kernel.org>
Cc: "Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"X86 ML" <x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
"Frank Rowand" <frank.rowand@sony.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re:Re: [PATCH] arch: x86: kernel: Add missing of_node_put() in devicetree.c
Date: Thu, 16 Jun 2022 00:50:16 +0800 (CST) [thread overview]
Message-ID: <525fcb48.8d90.1816845d84e.Coremail.windhl@126.com> (raw)
In-Reply-To: <CAL_JsqLfzz=Pxk=GaOyLpDf1u5WaMGE=UYSVf4MCp+7RRQSBeg@mail.gmail.com>
Hi, rob, thanks for your reply.
The of_find_xx will increase the refcounter for the local reference, so when
the function return, we need a decrease for the destroy of the local reference.
The device will not be freed as its refcounter will be sure larger than 0 when
the function returns.
All we need is to keep the refcounting balance, right?
At 2022-06-16 00:26:16, "Rob Herring" <robh@kernel.org> wrote:
>On Wed, Jun 15, 2022 at 9:03 AM Liang He <windhl@126.com> wrote:
>>
>> In dtb_setup_hpet(), of_find_compatible_node() will return a node
>> pointer with refcount incremented. We should use of_node_put() when it
>> is not used anymore.
>>
>> Signed-off-by: Liang He <windhl@126.com>
>> ---
>> arch/x86/kernel/devicetree.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
>> index 5cd51f25f446..6a386424ddf7 100644
>> --- a/arch/x86/kernel/devicetree.c
>> +++ b/arch/x86/kernel/devicetree.c
>> @@ -120,6 +120,9 @@ static void __init dtb_setup_hpet(void)
>> if (!dn)
>> return;
>> ret = of_address_to_resource(dn, 0, &r);
>> +
>> + of_node_put(dn);
>> +
>
>You don't want a put on success. If you are using the device, then you
>want to hold a reference to it.
>
>I would guess that if you have an error here and don't have your
>timer, you're not going to finish booting anyways.
>
>Finally, wouldn't dtb_lapic_setup() and dtb_add_ioapic() also need a
>similar change? But again, if those aren't initialized, you probably
>aren't getting very far.
>
>
>> if (ret) {
>> WARN_ON(1);
>> return;
>> --
>> 2.25.1
>>
prev parent reply other threads:[~2022-06-15 16:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 15:03 [PATCH] arch: x86: kernel: Add missing of_node_put() in devicetree.c Liang He
2022-06-15 15:33 ` Dave Hansen
2022-06-15 16:22 ` Rob Herring
2022-06-15 16:26 ` Rob Herring
2022-06-15 16:50 ` 和亮 [this message]
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=525fcb48.8d90.1816845d84e.Coremail.windhl@126.com \
--to=windhl@126.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=frank.rowand@sony.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=robh@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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