From: Guangshuo Li <lgs201920130244@gmail.com>
To: Justin Chen <justin.chen@broadcom.com>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Guangshuo Li <lgs201920130244@gmail.com>, stable@vger.kernel.org
Subject: [PATCH] net: bcmasp: fix MDIO child device leaks
Date: Mon, 21 Sep 2026 21:09:29 +0800 [thread overview]
Message-ID: <20260921130929.403129-1-lgs201920130244@gmail.com> (raw)
bcmasp_probe() populates MDIO child platform devices using
of_platform_populate(). If initialization later fails, the probe error
paths clean up interfaces and clock state without depopulating those
child devices.
The normal remove path has the same issue and leaves the populated
MDIO devices registered after the ASP driver is unbound.
Add a separate error path for failures that occur after the MDIO
devices have been populated, and call of_platform_depopulate() there.
Also depopulate the child devices during normal driver removal.
The issue was identified by a static analysis tool I developed and
confirmed by manual review.
Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
drivers/net/ethernet/broadcom/asp2/bcmasp.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
index 972474893a6b..c4087408a822 100644
--- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c
+++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
@@ -1309,14 +1309,14 @@ static int bcmasp_probe(struct platform_device *pdev)
sizeof(*priv->mda_filters), GFP_KERNEL);
if (!priv->mda_filters) {
ret = -ENOMEM;
- goto err_clock_disable;
+ goto err_depopulate;
}
priv->net_filters = devm_kcalloc(dev, priv->num_net_filters,
sizeof(*priv->net_filters), GFP_KERNEL);
if (!priv->net_filters) {
ret = -ENOMEM;
- goto err_clock_disable;
+ goto err_depopulate;
}
bcmasp_core_init_filters(priv);
@@ -1327,7 +1327,7 @@ static int bcmasp_probe(struct platform_device *pdev)
if (!ports_node) {
dev_warn(dev, "No ports found\n");
ret = -EINVAL;
- goto err_clock_disable;
+ goto err_depopulate;
}
i = 0;
@@ -1369,6 +1369,8 @@ static int bcmasp_probe(struct platform_device *pdev)
err_cleanup:
bcmasp_remove_intfs(priv);
+err_depopulate:
+ of_platform_depopulate(dev);
err_clock_disable:
clk_disable_unprepare(priv->clk);
@@ -1383,6 +1385,7 @@ static void bcmasp_remove(struct platform_device *pdev)
return;
bcmasp_remove_intfs(priv);
+ of_platform_depopulate(&pdev->dev);
}
static void bcmasp_shutdown(struct platform_device *pdev)
--
2.43.0
next reply other threads:[~2026-09-21 13:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 13:09 Guangshuo Li [this message]
2026-09-23 4:10 ` netdev-bot+sashiko
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=20260921130929.403129-1-lgs201920130244@gmail.com \
--to=lgs201920130244@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=horms@kernel.org \
--cc=justin.chen@broadcom.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 \
/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
all inboxes | Powered by JetHome®