* [PATCH net] net: bgmac: unregister the fixed PHY on probe failure and removal
@ 2026-11-20 0:30 Florian Fainelli
2026-11-20 0:32 ` netdev-bot+sinfo
0 siblings, 1 reply; 3+ messages in thread
From: Florian Fainelli @ 2026-11-20 0:30 UTC (permalink / raw)
To: netdev
Cc: rosenp, Florian Fainelli, Rafał Miłecki,
Broadcom internal kernel review list, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
open list
bgmac registers a fixed PHY, either for a chip without a PHY with
bgmac_phy_connect_direct(), or through a fixed-link device tree node with
of_phy_get_and_connect(). The error path of bgmac_enet_probe() and
bgmac_enet_remove() only call phy_disconnect(), and
bgmac_phy_connect_direct() does not release the PHY when connecting to
it fails. The phy_device is leaked, along with one of the limited number of
fixed PHY ids, which can make a later probe fail after repeated rebinds.
Unregister the fixed PHY after disconnecting from it, in the same way
as other drivers do, and when connecting to the PHY fails.
Fixes: c25b23b8a387 ("bgmac: register fixed PHY for ARM BCM470X / BCM5301X chipsets")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
drivers/net/ethernet/broadcom/bgmac.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 9ef7307edd41..54092bfacd18 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -15,6 +15,7 @@
#include <linux/bcm47xx_nvram.h>
#include <linux/phy.h>
#include <linux/phy_fixed.h>
+#include <linux/of_mdio.h>
#include <net/dsa.h>
#include "bgmac.h"
@@ -1475,6 +1476,7 @@ int bgmac_phy_connect_direct(struct bgmac *bgmac)
PHY_INTERFACE_MODE_MII);
if (err) {
dev_err(bgmac->dev, "Connecting PHY failed\n");
+ fixed_phy_unregister(phy_dev);
return err;
}
@@ -1482,6 +1484,22 @@ int bgmac_phy_connect_direct(struct bgmac *bgmac)
}
EXPORT_SYMBOL_GPL(bgmac_phy_connect_direct);
+/* Disconnect the PHY and release a fixed PHY registered for the connection. */
+static void bgmac_phy_disconnect(struct bgmac *bgmac)
+{
+ struct device_node *np = bgmac->dev->of_node;
+ struct phy_device *phydev = bgmac->net_dev->phydev;
+
+ if (!phydev)
+ return;
+
+ phy_disconnect(phydev);
+ if (np && of_phy_is_fixed_link(np))
+ of_phy_deregister_fixed_link(np);
+ else if (phy_is_pseudo_fixed_link(phydev))
+ fixed_phy_unregister(phydev);
+}
+
struct bgmac *bgmac_alloc(struct device *dev)
{
struct net_device *net_dev;
@@ -1575,7 +1593,7 @@ int bgmac_enet_probe(struct bgmac *bgmac)
return 0;
err_phy_disconnect:
- phy_disconnect(net_dev->phydev);
+ bgmac_phy_disconnect(bgmac);
err_dma_free:
bgmac_dma_free(bgmac);
err_out:
@@ -1587,7 +1605,7 @@ EXPORT_SYMBOL_GPL(bgmac_enet_probe);
void bgmac_enet_remove(struct bgmac *bgmac)
{
unregister_netdev(bgmac->net_dev);
- phy_disconnect(bgmac->net_dev->phydev);
+ bgmac_phy_disconnect(bgmac);
netif_napi_del(&bgmac->napi);
bgmac_dma_free(bgmac);
}
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] net: bgmac: unregister the fixed PHY on probe failure and removal
2026-11-20 0:30 [PATCH net] net: bgmac: unregister the fixed PHY on probe failure and removal Florian Fainelli
@ 2026-11-20 0:32 ` netdev-bot+sinfo
2026-11-20 0:34 ` Florian Fainelli
0 siblings, 1 reply; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-11-20 0:32 UTC (permalink / raw)
To: Florian Fainelli
Cc: netdev, rosenp, Rafał Miłecki,
Broadcom internal kernel review list, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: bgmac: unregister the fixed PHY on probe failure and removal
2026-11-20 0:32 ` netdev-bot+sinfo
@ 2026-11-20 0:34 ` Florian Fainelli
0 siblings, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2026-11-20 0:34 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: netdev, rosenp, Rafał Miłecki,
Broadcom internal kernel review list, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-kernel
On 11/19/26 16:32, netdev-bot+sinfo@kernel.org wrote:
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
This was discovered by a LLM as part of the larger review of the flow
accelerator support. It was not triggered because it affects an error
path and the driver unbind/removal path which is hardly ever exercised.
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-20 0:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 0:30 [PATCH net] net: bgmac: unregister the fixed PHY on probe failure and removal Florian Fainelli
2026-11-20 0:32 ` netdev-bot+sinfo
2026-11-20 0:34 ` Florian Fainelli
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®