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: <mpj5pvugs6gz3rhjtntshvbwbtmi463zg6jc4tatmvh5uuljhe@44kbv4di2b3s>
Date: Wed, 28 May 2025 22:23:34 +0300
From: Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>
To: Ai Chao <aichao@...inos.cn>
Cc: Johannes Berg <johannes@...solutions.net>, perex <perex@...ex.cz>,
        tiwai <tiwai@...e.com>,
        "kuninori.morimoto.gx" <kuninori.morimoto.gx@...esas.com>,
        lgirdwood <lgirdwood@...il.com>, broonie <broonie@...nel.org>,
        jbrunet <jbrunet@...libre.com>,
        "neil.armstrong" <neil.armstrong@...aro.org>,
        khilman <khilman@...libre.com>,
        "martin.blumenstingl" <martin.blumenstingl@...glemail.com>,
        "shengjiu.wang" <shengjiu.wang@...il.com>,
        "Xiubo.Lee" <Xiubo.Lee@...il.com>, festevam <festevam@...il.com>,
        nicoleotsuka <nicoleotsuka@...il.com>, shawnguo <shawnguo@...nel.org>,
        "s.hauer" <s.hauer@...gutronix.de>,
        "srinivas.kandagatla" <srinivas.kandagatla@...aro.org>,
        linux-sound <linux-sound@...r.kernel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>,
        linux-renesas-soc <linux-renesas-soc@...r.kernel.org>,
        linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
        linux-amlogic <linux-amlogic@...ts.infradead.org>,
        imx <imx@...ts.linux.dev>, kernel <kernel@...gutronix.de>,
        linux-arm-msm <linux-arm-msm@...r.kernel.org>
Subject: Re: [PATCH v2 2/6] ASoC: aoa: Use helper function
 for_each_child_of_node_scoped()

On Mon, May 26, 2025 at 04:20:37PM +0800, Ai Chao wrote:
> 
> Hi Johannes:
> > > Hi Johannes:
> > > 
> > > > > "simplifies the code" is no need to callof_node_put() .
> > > > Fair. Except that's not what you _actually_ changed here. Like I said,
> > > > either it's buggy before or after.
> > > > 
> > > In the function i2sbus_probe, it not return a struct device_node, so , I
> > > think function for_each_child_of_node_scoped is better than
> > > for_each_child_of_node.
> > You still haven't explained why it's even correct.
> > 
> > johannes
> 
> 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()).

This is not complete story, you missed the second part of it.

> 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.
> 
> Best regards,
> Ai Chao

-- 
With best wishes
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ