[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e82c9860-29b9-4e21-b738-0a61880ce184@kernel.org>
Date: Wed, 21 May 2025 08:02:28 +0200
From: Krzysztof Kozlowski <krzk@...nel.org>
To: Ai Chao <aichao@...inos.cn>,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
srinivas.kandagatla@...aro.org, lgirdwood@...il.com, broonie@...nel.org,
perex@...ex.cz, tiwai@...e.com
Cc: linux-sound@...r.kernel.org, linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 6/6] ASoC: qcom: Use helper function
for_each_child_of_node_scoped()
On 21/05/2025 03:58, Ai Chao wrote:
> Hi Krzysztof :
>
> Thanks for your help.
>
> 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.
Don't lecture us on the API, we know it.
>
> The of_node_put() function is used to decrement the node's
> reference count. When the reference count drops to zero, the kernel
> releases the memory occupied by the node.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.
Except top posting, you did not answer the comment at all. Explaining
all this in view of existing code means you do not understand the code.
Best regards,
Krzysztof
Powered by blists - more mailing lists