Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Ai Chao <aichao@kylinos.cn>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	srinivas.kandagatla@linaro.org, lgirdwood@gmail.com,
	broonie@kernel.org, perex@perex.cz, tiwai@suse.com
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 08:02:28 +0200	[thread overview]
Message-ID: <e82c9860-29b9-4e21-b738-0a61880ce184@kernel.org> (raw)
In-Reply-To: <758b0ad2-e337-4be6-a7da-4d5af8b193d1@kylinos.cn>

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

      reply	other threads:[~2025-05-21  6:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-20  9:11 [PATCH 0/6] Use helper function for_each_child_of_node_scoped() 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
2025-05-21  6:02       ` Krzysztof Kozlowski [this message]

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=e82c9860-29b9-4e21-b738-0a61880ce184@kernel.org \
    --to=krzk@kernel.org \
    --cc=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