From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Wang Qing <wangqing@vivo.com>,
"David S . Miller" <davem@davemloft.net>,
Sasha Levin <sashal@kernel.org>,
kuba@kernel.org, vigneshr@ti.com, grygorii.strashko@ti.com,
vladimir.oltean@nxp.com, leon@kernel.org, peter.ujfalusi@ti.com,
michael@walle.cc, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.15 13/29] net: ethernet: ti: add missing of_node_put before return
Date: Mon, 20 Dec 2021 20:57:34 -0500 [thread overview]
Message-ID: <20211221015751.116328-13-sashal@kernel.org> (raw)
In-Reply-To: <20211221015751.116328-1-sashal@kernel.org>
From: Wang Qing <wangqing@vivo.com>
[ Upstream commit be565ec71d1d59438bed0c7ed0a252a327e0b0ef ]
Fix following coccicheck warning:
WARNING: Function "for_each_child_of_node"
should have of_node_put() before return.
Early exits from for_each_child_of_node should decrement the
node reference counter.
Signed-off-by: Wang Qing <wangqing@vivo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 29 ++++++++++++++++--------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 130346f74ee8a..8829926e2c676 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1844,13 +1844,14 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
if (ret < 0) {
dev_err(dev, "%pOF error reading port_id %d\n",
port_np, ret);
- return ret;
+ goto of_node_put;
}
if (!port_id || port_id > common->port_num) {
dev_err(dev, "%pOF has invalid port_id %u %s\n",
port_np, port_id, port_np->name);
- return -EINVAL;
+ ret = -EINVAL;
+ goto of_node_put;
}
port = am65_common_get_port(common, port_id);
@@ -1866,8 +1867,10 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
(AM65_CPSW_NU_FRAM_PORT_OFFSET * (port_id - 1));
port->slave.mac_sl = cpsw_sl_get("am65", dev, port->port_base);
- if (IS_ERR(port->slave.mac_sl))
- return PTR_ERR(port->slave.mac_sl);
+ if (IS_ERR(port->slave.mac_sl)) {
+ ret = PTR_ERR(port->slave.mac_sl);
+ goto of_node_put;
+ }
port->disabled = !of_device_is_available(port_np);
if (port->disabled) {
@@ -1880,7 +1883,7 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
ret = PTR_ERR(port->slave.ifphy);
dev_err(dev, "%pOF error retrieving port phy: %d\n",
port_np, ret);
- return ret;
+ goto of_node_put;
}
port->slave.mac_only =
@@ -1889,10 +1892,12 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
/* get phy/link info */
if (of_phy_is_fixed_link(port_np)) {
ret = of_phy_register_fixed_link(port_np);
- if (ret)
- return dev_err_probe(dev, ret,
+ if (ret) {
+ ret = dev_err_probe(dev, ret,
"failed to register fixed-link phy %pOF\n",
port_np);
+ goto of_node_put;
+ }
port->slave.phy_node = of_node_get(port_np);
} else {
port->slave.phy_node =
@@ -1902,14 +1907,15 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
if (!port->slave.phy_node) {
dev_err(dev,
"slave[%d] no phy found\n", port_id);
- return -ENODEV;
+ ret = -ENODEV;
+ goto of_node_put;
}
ret = of_get_phy_mode(port_np, &port->slave.phy_if);
if (ret) {
dev_err(dev, "%pOF read phy-mode err %d\n",
port_np, ret);
- return ret;
+ goto of_node_put;
}
ret = of_get_mac_address(port_np, port->slave.mac_addr);
@@ -1932,6 +1938,11 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
}
return 0;
+
+of_node_put:
+ of_node_put(port_np);
+ of_node_put(node);
+ return ret;
}
static void am65_cpsw_pcpu_stats_free(void *data)
--
2.34.1
next prev parent reply other threads:[~2021-12-21 1:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20211221015751.116328-1-sashal@kernel.org>
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 04/29] mac80211: fix TCP performance on mesh interface Sasha Levin
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 05/29] mac80211: set up the fwd_skb->dev for mesh forwarding Sasha Levin
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 06/29] mac80211: fix a memory leak where sta_info is not freed Sasha Levin
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 07/29] nl80211: reset regdom when reloading regdb Sasha Levin
2021-12-25 18:23 ` Sedat Dilek
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 08/29] iwlwifi: fix LED dependencies Sasha Levin
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 09/29] phonet: refcount leak in pep_sock_accep Sasha Levin
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 10/29] net: usb: qmi_wwan: add Telit 0x1070 composition Sasha Levin
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 12/29] net: bcmgenet: Fix NULL vs IS_ERR() checking Sasha Levin
2021-12-21 1:57 ` Sasha Levin [this message]
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 15/29] mac80211: Fix the size used for building probe request Sasha Levin
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 16/29] mac80211: update channel context before station state Sasha Levin
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 17/29] mac80211: do drv_reconfig_complete() before restarting all Sasha Levin
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 21/29] net: usb: lan78xx: add Allied Telesis AT29M2-AF Sasha Levin
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 22/29] virtio_net: fix rx_drops stat for small pkts Sasha Levin
2021-12-21 1:57 ` [PATCH AUTOSEL 5.15 23/29] bpf: Make 32->64 bounds propagation slightly more robust Sasha Levin
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=20211221015751.116328-13-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=grygorii.strashko@ti.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@walle.cc \
--cc=netdev@vger.kernel.org \
--cc=peter.ujfalusi@ti.com \
--cc=stable@vger.kernel.org \
--cc=vigneshr@ti.com \
--cc=vladimir.oltean@nxp.com \
--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).