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: <3869e6fc-1cbf-4113-9b34-0cbb5d4b5176@kylinos.cn>
Date: Mon, 26 May 2025 16:53:42 +0800
From: Ai Chao <aichao@...inos.cn>
To: Christophe Leroy <christophe.leroy@...roup.eu>, perex@...ex.cz,
 tiwai@...e.com, johannes@...solutions.net, kuninori.morimoto.gx@...esas.com,
 lgirdwood@...il.com, broonie@...nel.org, jbrunet@...libre.com,
 neil.armstrong@...aro.org, khilman@...libre.com,
 martin.blumenstingl@...glemail.com, shengjiu.wang@...il.com,
 Xiubo.Lee@...il.com, festevam@...il.com, nicoleotsuka@...il.com,
 shawnguo@...nel.org, s.hauer@...gutronix.de, srinivas.kandagatla@...aro.org
Cc: linux-sound@...r.kernel.org, linux-kernel@...r.kernel.org,
 linuxppc-dev@...ts.ozlabs.org, linux-renesas-soc@...r.kernel.org,
 linux-arm-kernel@...ts.infradead.org, linux-amlogic@...ts.infradead.org,
 imx@...ts.linux.dev, kernel@...gutronix.de, linux-arm-msm@...r.kernel.org
Subject: Re: [PATCH v2 2/6] ASoC: aoa: Use helper function
 for_each_child_of_node_scoped()

Hi Christophe:

>> The for_each_child_of_node_scoped() helper provides a scope-based
>> clean-up functionality to put the device_node automatically, and
>> as such, there is no need to call of_node_put() directly.
>
> I don't understand this explanation.
>
> You say "no need to call of_node_put()" and the only thing you do in 
> addition to changing from for_each_child_of_node() to 
> for_each_child_of_node_scoped() is to _add_ a new call to of_node_put().
>
> I would expect to see a _removal_ of some of_node_put() when I read 
> your description.
>
>>       }
>> +    of_node_put(sound);
>> +

The for_each_child_of_node() function is used to iterate over all child 
nodes of a device tree node.  During each iteration, it retrieves a 
pointer to the child node via of_get_next_child() and automatically 
increments the node's reference count (of_node_get()). Each call to 
of_get_next_child() increases the reference count (refcount) of the 
returned child node, ensuring that the node is not freed while in use.
for_each_child_of_node() increments the child node's reference count in 
each iteration but does not decrement it automatically.
If of_node_put() is not called manually, the reference count will never 
reach zero, resulting in a memory leak of the node.

In function i2sbus_add_dev, it used device_node out of 
for_each_child_of_node(){},  it need to add a new call to 
of_node_put(sound) to reference count.

In function i2cbus_probe, it used device_node in 
for_each_child_of_node(){}, used for_each_child_of_node_scoped() is 
better than for_each_child_of_node().

Best regards,
Ai Chao

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ