lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <525fcb48.8d90.1816845d84e.Coremail.windhl@126.com>
Date:   Thu, 16 Jun 2022 00:50:16 +0800 (CST)
From:   和亮 <windhl@....com>
To:     "Rob Herring" <robh@...nel.org>
Cc:     "Thomas Gleixner" <tglx@...utronix.de>,
        "Ingo Molnar" <mingo@...hat.com>, "Borislav Petkov" <bp@...en8.de>,
        "Dave Hansen" <dave.hansen@...ux.intel.com>,
        "X86 ML" <x86@...nel.org>, "H. Peter Anvin" <hpa@...or.com>,
        "Frank Rowand" <frank.rowand@...y.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re:Re: [PATCH] arch: x86: kernel: Add missing of_node_put() in
 devicetree.c



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@...nel.org> wrote:
>On Wed, Jun 15, 2022 at 9:03 AM Liang He <windhl@....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@....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
>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ