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: <87cyk97ufp.fsf@mail.lhotse>
Date: Wed, 09 Oct 2024 15:48:42 +1100
From: Michael Ellerman <mpe@...erman.id.au>
To: Christophe Leroy <christophe.leroy@...roup.eu>, Markus Elfring
 <Markus.Elfring@....de>, linuxppc-dev@...ts.ozlabs.org, Jani Nikula
 <jani.nikula@...el.com>, Madhavan Srinivasan <maddy@...ux.ibm.com>, Naveen
 N Rao <naveen@...nel.org>, Nicholas Piggin <npiggin@...il.com>, Paul
 Mackerras <paulus@...ba.org>, Stephen Rothwell <sfr@...b.auug.org.au>,
 Thomas Zimmermann <tzimmermann@...e.de>
Cc: LKML <linux-kernel@...r.kernel.org>, kernel-janitors@...r.kernel.org,
 Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Subject: Re: [PATCH] powermac: Call of_node_put(bk_node) only once in
 pmac_has_backlight_type()

Christophe Leroy <christophe.leroy@...roup.eu> writes:
> Le 02/10/2024 à 22:02, Markus Elfring a écrit :
>> From: Markus Elfring <elfring@...rs.sourceforge.net>
>> Date: Wed, 2 Oct 2024 21:50:27 +0200
>> 
>> An of_node_put(bk_node) call was immediately used after a pointer check
>> for an of_get_property() call in this function implementation.
>> Thus call such a function only once instead directly before the check.
>
> It seems pointless to perform a put immediately after a get. Shouldn't 
> of_find_property() be used instead ? And then of_property_read_string() 
> would probably be better.
>
> Maybe you can even use of_property_match_string().

Yes that would clean it up nicely I think, eg:

int pmac_has_backlight_type(const char *type)
{
        struct device_node* bk_node = of_find_node_by_name(NULL, "backlight");
        int i;

        i = of_property_match_string(bk_node, "backlight-control", type);
        of_node_put(bk_node);

        return i >= 0;
}

cheers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ