mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ai Chao <aichao@kylinos.cn>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	srinivas.kandagatla@linaro.org, lgirdwood@gmail.com,
	broonie@kernel.org, perex@perex.cz, tiwai@suse.com,
	aichao@kylinos.cn
Cc: linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/6] ASoC: qcom: Use helper function for_each_child_of_node_scoped()
Date: Wed, 21 May 2025 09:58:54 +0800	[thread overview]
Message-ID: <758b0ad2-e337-4be6-a7da-4d5af8b193d1@kylinos.cn> (raw)
In-Reply-To: <eca8721c-305f-4053-8df0-0347cc869325@linaro.org>

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.

     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.

On 2025/5/20 17:19, Krzysztof Kozlowski wrote:
> On 20/05/2025 11:11, Ai Chao wrote:
>> 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 do not see any of_node_put() there, so I don't understand what is the
> benefit of this and how this commit msg explains reason behind the change.
>
> Best regards,
> Krzysztof

  reply	other threads:[~2025-05-21  1:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-20  9:11 [PATCH 0/6] " Ai Chao
2025-05-20  9:11 ` [PATCH 1/6] ASoC: ppc: " Ai Chao
2025-05-20  9:11 ` [PATCH 2/6] ASoC: aoa: " Ai Chao
2025-05-20  9:11 ` [PATCH 3/6] ASoC: renesas: " Ai Chao
2025-05-21 23:43   ` Kuninori Morimoto
2025-05-20  9:11 ` [PATCH 4/6] ASoC: meson: " Ai Chao
2025-05-20 21:43   ` kernel test robot
2025-05-20  9:11 ` [PATCH 5/6] ASoC: imx-card: " Ai Chao
2025-05-20  9:11 ` [PATCH 6/6] ASoC: qcom: " Ai Chao
2025-05-20  9:19   ` Krzysztof Kozlowski
2025-05-21  1:58     ` Ai Chao [this message]
2025-05-21  6:02       ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=758b0ad2-e337-4be6-a7da-4d5af8b193d1@kylinos.cn \
    --to=aichao@kylinos.cn \
    --cc=broonie@kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®