From: Liang He <windhl@126.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, windhl@126.com, netdev@vger.kernel.org
Subject: [PATCH] ftgmac100: Hold reference returned by of_get_child_by_name()
Date: Mon, 4 Jul 2022 23:18:19 +0800 [thread overview]
Message-ID: <20220704151819.279513-1-windhl@126.com> (raw)
In ftgmac100_probe(), we should hold the refernece returned by
of_get_child_by_name() and use it to call of_node_put() for
reference balance.
Signed-off-by: Liang He <windhl@126.com>
---
drivers/net/ethernet/faraday/ftgmac100.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 5231818943c6..e50bd7beb09b 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1770,7 +1770,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
int irq;
struct net_device *netdev;
struct ftgmac100 *priv;
- struct device_node *np;
+ struct device_node *np, *child_np;
int err = 0;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1883,7 +1883,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
/* Display what we found */
phy_attached_info(phy);
- } else if (np && !of_get_child_by_name(np, "mdio")) {
+ } else if (np && !(child_np = of_get_child_by_name(np, "mdio"))) {
/* Support legacy ASPEED devicetree descriptions that decribe a
* MAC with an embedded MDIO controller but have no "mdio"
* child node. Automatically scan the MDIO bus for available
@@ -1901,6 +1901,8 @@ static int ftgmac100_probe(struct platform_device *pdev)
}
}
+ if (child_np)
+ of_node_put(child_np);
if (priv->is_aspeed) {
err = ftgmac100_setup_clk(priv);
--
2.25.1
next reply other threads:[~2022-07-04 15:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 15:18 Liang He [this message]
2022-07-06 1:48 ` [PATCH] ftgmac100: Hold reference returned by of_get_child_by_name() Jakub Kicinski
2022-07-06 1:58 ` Liang He
2022-07-06 8:55 ` Liang He
2022-07-06 16:34 ` Jakub Kicinski
2022-07-07 1:28 ` Liang He
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=20220704151819.279513-1-windhl@126.com \
--to=windhl@126.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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).