From: Wentao Liang <vulab@iscas.ac.cn>
To: andrew+netdev@lunn.ch
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
pabeni@redhat.com, wellslutw@gmail.com,
Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] net: ethernet: sunplus: Fix port node leak in spl2sw_probe()
Date: Thu, 17 Sep 2026 11:43:47 +0000 [thread overview]
Message-ID: <20260917114347.2149525-1-vulab@iscas.ac.cn> (raw)
spl2sw_get_eth_child_node() returns a child node with a reference held,
but spl2sw_probe() never releases it: the node is leaked on the
"failed to get phy-mode" and "failed to get phy-handle" continue paths,
on the out_unregister_dev error paths and when the loop ends. Declare
the node inside the loop with __free(device_node) so the reference is
released on every iteration exit.
Fixes: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/net/ethernet/sunplus/spl2sw_driver.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/ethernet/sunplus/spl2sw_driver.c
index fdc9c3196738..c124e5ef3588 100644
--- a/drivers/net/ethernet/sunplus/spl2sw_driver.c
+++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c
@@ -320,7 +320,6 @@ static struct device_node *spl2sw_get_eth_child_node(struct device_node *ether_n
static int spl2sw_probe(struct platform_device *pdev)
{
struct device_node *eth_ports_np __free(device_node) = NULL;
- struct device_node *port_np;
struct spl2sw_common *comm;
struct device_node *phy_np;
phy_interface_t phy_mode;
@@ -418,6 +417,8 @@ static int spl2sw_probe(struct platform_device *pdev)
}
for (i = 0; i < MAX_NETDEV_NUM; i++) {
+ struct device_node *port_np __free(device_node) = NULL;
+
/* Get port@i of node ethernet-ports. */
port_np = spl2sw_get_eth_child_node(eth_ports_np, i);
if (!port_np)
--
2.34.1
reply other threads:[~2026-09-17 11:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260917114347.2149525-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=wellslutw@gmail.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