From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Qing Wang <wangqing@vivo.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: phy: add missing of_node_put before return
Date: Mon, 13 Dec 2021 11:03:12 +0000 [thread overview]
Message-ID: <YbcocBZBAJaZ0Rf6@shell.armlinux.org.uk> (raw)
In-Reply-To: <1639388689-64038-1-git-send-email-wangqing@vivo.com>
On Mon, Dec 13, 2021 at 01:44:49AM -0800, Qing Wang wrote:
> From: Wang Qing <wangqing@vivo.com>
>
> Fix following coccicheck warning:
> WARNING: Function "for_each_available_child_of_node"
> should have of_node_put() before return.
>
> Early exits from for_each_available_child_of_node should decrement the
> node reference counter.
Most *definitely* NAK. Coccicheck is most definitely wrong on this one,
and we will probably need some way to tell people not to believe
coccicheck on this.
In this path, the DT node is assigned to a struct device. This _must_
be reference counted. device_set_node() does not increment the
reference count, nor does of_fwnode_handle(). The reference count
here is passed from this code over to the struct device.
Adding an of_node_put() will break this.
This must _never_ be "fixed" no matter how much coccicheck complains,
as fixing the warning _will_ introduce a refcounting bug.
I'll send a patch adding a comment to this effect.
Thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2021-12-13 11:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-13 9:44 [PATCH] net: phy: add missing of_node_put before return Qing Wang
2021-12-13 11:03 ` Russell King (Oracle) [this message]
[not found] ` <ALAA5ABiE1JEtj4aLwAwtqpi.9.1639393400698.Hmail.wangqing@vivo.com.@PFliY29jQlpCQUphWjBSZjZAc2hlbGwuYXJtbGludXgub3JnLnVrPg==>
2021-12-14 2:14 ` 王擎
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=YbcocBZBAJaZ0Rf6@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=wangqing@vivo.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;
as well as URLs for NNTP newsgroup(s).