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] [thread-next>] [day] [month] [year] [list]
Message-ID: <e7a1b608-2bad-41d4-844a-07fd73818bb3@kernel.org>
Date: Wed, 12 Feb 2025 06:47:20 +0100
From: Krzysztof Kozlowski <krzk@...nel.org>
To: Zhang Zekun <zhangzekun11@...wei.com>, robh@...nel.org,
 saravanak@...gle.com, justin.chen@...adcom.com,
 florian.fainelli@...adcom.com, andrew+netdev@...n.ch, kuba@...nel.org,
 o.rempel@...gutronix.de, kory.maincent@...tlin.com,
 jacopo+renesas@...ndi.org, kieran.bingham+renesas@...asonboard.com,
 laurent.pinchart+renesas@...asonboard.com, maddy@...ux.ibm.com,
 mpe@...erman.id.au, npiggin@...il.com, olteanv@...il.com,
 davem@...emloft.net, taras.chornyi@...ision.eu, edumazet@...gle.com,
 pabeni@...hat.com, sudeep.holla@....com, cristian.marussi@....com
Cc: arm-scmi@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
 linux-media@...r.kernel.org, netdev@...r.kernel.org,
 devicetree@...r.kernel.org, chenjun102@...wei.com
Subject: Re: [PATCH 1/9] of: Add warpper function
 of_find_node_by_name_balanced()

On 07/02/2025 02:31, Zhang Zekun wrote:
> There are many drivers use of_find_node_by_name() with a not-NULL
> device_node pointer, and a number of callers would require a call to
> of_node_get() before using it. There are also some drivers who forget
> to call of_node_get() which would cause a ref count leak[1]. So, Add a
> wraper function for of_find_node_by_name(), drivers may use this function
> to call of_find_node_by_name() with the refcount already balanced.
> 
> [1] https://lore.kernel.org/all/20241024015909.58654-1-zhangzekun11@huawei.com/
> 
> Signed-off-by: Zhang Zekun <zhangzekun11@...wei.com>
> ---
>  include/linux/of.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/include/linux/of.h b/include/linux/of.h
> index eaf0e2a2b75c..b7c6d7ff278c 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -268,6 +268,11 @@ static inline const char *of_node_full_name(const struct device_node *np)
>  #define for_each_of_allnodes(dn) for_each_of_allnodes_from(NULL, dn)
>  extern struct device_node *of_find_node_by_name(struct device_node *from,
>  	const char *name);
> +static inline struct device_node *of_find_node_by_name_balanced(struct device_node *from,
> +								const char *name)
> +{
> +	return of_find_node_by_name(of_node_get(from), name);

I don't think that solution to people not reading API description is to
create more API with similar but a bit different behavior, especially
undocumented.

Best regards,
Krzysztof

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ