Netdev List
 help / color / mirror / Atom feed
* [PATCH v2 2/2] bcm63xx_enet: Adjustments for clock management
@ 2026-11-27 14:01 Markus Elfring
  2026-11-27 14:03 ` [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() Markus Elfring
  2026-11-27 14:07 ` [PATCH net v2 2/2] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions Markus Elfring
  0 siblings, 2 replies; 7+ messages in thread
From: Markus Elfring @ 2026-11-27 14:01 UTC (permalink / raw)
  To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam,
	Jakub Kicinski, Jonas Gorski, Paolo Abeni, Simon Horman
  Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet,
	Florian Fainelli, Frank Li, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 27 Nov 2026 13:50:43 +0100

Two update suggestions were taken into account from source code analysis.

Markus Elfring (2):
  Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove()
  Use devm_clk_get_enabled() in two probe functions

V2:
An initial patch was converted into a small patch series.

 drivers/net/ethernet/broadcom/bcm63xx_enet.c | 31 +++++---------------
 1 file changed, 8 insertions(+), 23 deletions(-)

-- 
2.56.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove()
  2026-11-27 14:01 [PATCH v2 2/2] bcm63xx_enet: Adjustments for clock management Markus Elfring
@ 2026-11-27 14:03 ` Markus Elfring
  2026-11-27 14:14   ` netdev-bot+sinfo
                     ` (2 more replies)
  2026-11-27 14:07 ` [PATCH net v2 2/2] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions Markus Elfring
  1 sibling, 3 replies; 7+ messages in thread
From: Markus Elfring @ 2026-11-27 14:03 UTC (permalink / raw)
  To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam,
	Jakub Kicinski, Jonas Gorski, Paolo Abeni, Simon Horman
  Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet,
	Florian Fainelli, Frank Li, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 27 Nov 2026 11:52:23 +0100

A clk_prepare_enable(priv->phy_clk) call was specified within an if branch
in the implementation of the function “bcm_enet_probe” while
a clk_disable_unprepare(priv->phy_clk) call was unconditionally performed
in the implementation of the function “bcm_enet_remove”.
Move this clk_disable_unprepare() call into a corresponding if branch.

Fixes: 7e697ce99ceb09538cdc1dfa9ebb3db60236b0a7 ("bcm63xx_enet: use managed functions for clock/ioremap")
Cc: stable@vger.kernel.org
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/broadcom/bcm63xx_enet.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index f6595fdc888d..cc9a5cd2a2a3 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -1915,6 +1915,9 @@ static void bcm_enet_remove(struct platform_device *pdev)
 	enet_writel(priv, 0, ENET_MIISC_REG);
 
 	if (priv->has_phy) {
+		if (!priv->use_external_mii)
+			clk_disable_unprepare(priv->phy_clk);
+
 		mdiobus_unregister(priv->mii_bus);
 		mdiobus_free(priv->mii_bus);
 	} else {
@@ -1927,7 +1930,6 @@ static void bcm_enet_remove(struct platform_device *pdev)
 	}
 
 	/* disable hw block clocks */
-	clk_disable_unprepare(priv->phy_clk);
 	clk_disable_unprepare(priv->mac_clk);
 
 	free_netdev(dev);
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net v2 2/2] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions
  2026-11-27 14:01 [PATCH v2 2/2] bcm63xx_enet: Adjustments for clock management Markus Elfring
  2026-11-27 14:03 ` [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() Markus Elfring
@ 2026-11-27 14:07 ` Markus Elfring
  1 sibling, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2026-11-27 14:07 UTC (permalink / raw)
  To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam,
	Jakub Kicinski, Jonas Gorski, Paolo Abeni, Simon Horman
  Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet,
	Florian Fainelli, Frank Li, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 27 Nov 2026 13:30:17 +0100

* Reuse existing functionality from devm_clk_get_enabled() instead of
  keeping duplicate source code.

* Delete a clk_disable_unprepare() call on error handling paths
  and in the implementation of two remove functions.

* Omit two labels.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/broadcom/bcm63xx_enet.c | 27 ++++----------------
 1 file changed, 5 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index cc9a5cd2a2a3..d9466609e7c1 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -1751,14 +1751,11 @@ static int bcm_enet_probe(struct platform_device *pdev)
 	priv->irq_rx = irq_rx;
 	priv->irq_tx = irq_tx;
 
-	priv->mac_clk = devm_clk_get(&pdev->dev, "enet");
+	priv->mac_clk = devm_clk_get_enabled(&pdev->dev, "enet");
 	if (IS_ERR(priv->mac_clk)) {
 		ret = PTR_ERR(priv->mac_clk);
 		goto out;
 	}
-	ret = clk_prepare_enable(priv->mac_clk);
-	if (ret)
-		goto out;
 
 	/* initialize default and fetch platform data */
 	priv->rx_ring_size = BCMENET_DEF_RX_DESC;
@@ -1792,11 +1789,11 @@ static int bcm_enet_probe(struct platform_device *pdev)
 		if (IS_ERR(priv->phy_clk)) {
 			ret = PTR_ERR(priv->phy_clk);
 			priv->phy_clk = NULL;
-			goto out_disable_clk_mac;
+			goto out;
 		}
 		ret = clk_prepare_enable(priv->phy_clk);
 		if (ret)
-			goto out_disable_clk_mac;
+			goto out;
 	}
 
 	/* do minimal hardware init to be able to probe mii bus */
@@ -1890,8 +1887,6 @@ static int bcm_enet_probe(struct platform_device *pdev)
 	enet_writel(priv, 0, ENET_MIISC_REG);
 	clk_disable_unprepare(priv->phy_clk);
 
-out_disable_clk_mac:
-	clk_disable_unprepare(priv->mac_clk);
 out:
 	free_netdev(dev);
 	return ret;
@@ -1929,9 +1924,6 @@ static void bcm_enet_remove(struct platform_device *pdev)
 				       bcm_enet_mdio_write_mii);
 	}
 
-	/* disable hw block clocks */
-	clk_disable_unprepare(priv->mac_clk);
-
 	free_netdev(dev);
 }
 
@@ -2694,14 +2686,11 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
 		goto out;
 	}
 
-	priv->mac_clk = devm_clk_get(&pdev->dev, "enetsw");
+	priv->mac_clk = devm_clk_get_enabled(&pdev->dev, "enetsw");
 	if (IS_ERR(priv->mac_clk)) {
 		ret = PTR_ERR(priv->mac_clk);
 		goto out;
 	}
-	ret = clk_prepare_enable(priv->mac_clk);
-	if (ret)
-		goto out;
 
 	priv->rx_chan = 0;
 	priv->tx_chan = 1;
@@ -2720,7 +2709,7 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
 
 	ret = register_netdev(dev);
 	if (ret)
-		goto out_disable_clk;
+		goto out;
 
 	netif_carrier_off(dev);
 	platform_set_drvdata(pdev, dev);
@@ -2729,8 +2718,6 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
 
 	return 0;
 
-out_disable_clk:
-	clk_disable_unprepare(priv->mac_clk);
 out:
 	free_netdev(dev);
 	return ret;
@@ -2740,16 +2727,12 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
 /* exit func, stops hardware and unregisters netdevice */
 static void bcm_enetsw_remove(struct platform_device *pdev)
 {
-	struct bcm_enet_priv *priv;
 	struct net_device *dev;
 
 	/* stop netdevice */
 	dev = platform_get_drvdata(pdev);
-	priv = netdev_priv(dev);
 	unregister_netdev(dev);
 
-	clk_disable_unprepare(priv->mac_clk);
-
 	free_netdev(dev);
 }
 
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove()
  2026-11-27 14:03 ` [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() Markus Elfring
@ 2026-11-27 14:14   ` netdev-bot+sinfo
  2026-11-27 14:26   ` Jonas Gorski
  2026-11-28 14:31   ` [PATCH net v2 " netdev-bot+sashiko
  2 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sinfo @ 2026-11-27 14:14 UTC (permalink / raw)
  To: Markus Elfring
  Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam,
	Jakub Kicinski, Jonas Gorski, Paolo Abeni, Simon Horman, LKML,
	kernel-janitors, Andy Shevchenko, Christophe Jaillet,
	Florian Fainelli, Frank Li, Julia Lawall

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] 7+ messages in thread

* Re: [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove()
  2026-11-27 14:03 ` [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() Markus Elfring
  2026-11-27 14:14   ` netdev-bot+sinfo
@ 2026-11-27 14:26   ` Jonas Gorski
  2026-11-27 14:33     ` [v2 " Markus Elfring
  2026-11-28 14:31   ` [PATCH net v2 " netdev-bot+sashiko
  2 siblings, 1 reply; 7+ messages in thread
From: Jonas Gorski @ 2026-11-27 14:26 UTC (permalink / raw)
  To: Markus Elfring
  Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam,
	Jakub Kicinski, Paolo Abeni, Simon Horman, LKML, kernel-janitors,
	Andy Shevchenko, Christophe Jaillet, Florian Fainelli, Frank Li,
	Julia Lawall

On Fri, Nov 27, 2026 at 3:04 PM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 27 Nov 2026 11:52:23 +0100
>
> A clk_prepare_enable(priv->phy_clk) call was specified within an if branch
> in the implementation of the function “bcm_enet_probe” while
> a clk_disable_unprepare(priv->phy_clk) call was unconditionally performed
> in the implementation of the function “bcm_enet_remove”.
> Move this clk_disable_unprepare() call into a corresponding if branch.
>
> Fixes: 7e697ce99ceb09538cdc1dfa9ebb3db60236b0a7 ("bcm63xx_enet: use managed functions for clock/ioremap")
> Cc: stable@vger.kernel.org
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/ethernet/broadcom/bcm63xx_enet.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
> index f6595fdc888d..cc9a5cd2a2a3 100644
> --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
> +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
> @@ -1915,6 +1915,9 @@ static void bcm_enet_remove(struct platform_device *pdev)
>         enet_writel(priv, 0, ENET_MIISC_REG);
>
>         if (priv->has_phy) {
> +               if (!priv->use_external_mii)
> +                       clk_disable_unprepare(priv->phy_clk);
> +
>                 mdiobus_unregister(priv->mii_bus);
>                 mdiobus_free(priv->mii_bus);
>         } else {
> @@ -1927,7 +1930,6 @@ static void bcm_enet_remove(struct platform_device *pdev)
>         }
>
>         /* disable hw block clocks */
> -       clk_disable_unprepare(priv->phy_clk);

clk_disable_unprepare() is NULL-safe, so it's fine to call it
unconditionally. This change fixes nothing, just adds potential
breakage (disabling the phy clock before unregistering the mdio bus
feels risky).

>         clk_disable_unprepare(priv->mac_clk);

Best regards,
Jonas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove()
  2026-11-27 14:26   ` Jonas Gorski
@ 2026-11-27 14:33     ` Markus Elfring
  0 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2026-11-27 14:33 UTC (permalink / raw)
  To: Jonas Gorski, netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
	Hemanth Selam, Jakub Kicinski, Paolo Abeni, Simon Horman
  Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet,
	Florian Fainelli, Frank Li, Julia Lawall

> clk_disable_unprepare() is NULL-safe, so it's fine to call it
> unconditionally.

Where is such an API property documented?


>                  This change fixes nothing, just adds potential
> breakage (disabling the phy clock before unregistering the mdio bus
> feels risky).
Will involved software dependencies be clarified in more desirable ways?

Regards,
Markus

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove()
  2026-11-27 14:03 ` [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() Markus Elfring
  2026-11-27 14:14   ` netdev-bot+sinfo
  2026-11-27 14:26   ` Jonas Gorski
@ 2026-11-28 14:31   ` netdev-bot+sashiko
  2 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-11-28 14:31 UTC (permalink / raw)
  To: Markus.Elfring
  Cc: netdev, andrew+netdev, davem, edumazet, hemanth.selam, kuba,
	jonas.gorski, pabeni, horms, linux-kernel, kernel-janitors,
	andriy.shevchenko, christophe.jaillet, f.fainelli, Frank.Li,
	Julia.Lawall

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 (1) · Medium: 1 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch fixes a bug that does not exist, but carries Fixes:
  and Cc: stable tags.
- [Low] The patch guards clk_disable_unprepare(priv->phy_clk) in
  bcm_enet_remove() but leaves the identical unconditional call at the…
- [Low] In bcm_enet_remove() the patch moves
  clk_disable_unprepare(priv->phy_clk) ahead of…

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but it is in the
  same probe/remove pair and survives the whole series.

--

bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove()

This patch moves clk_disable_unprepare(priv->phy_clk) in bcm_enet_remove()
into the has_phy branch and guards it with !priv->use_external_mii. That
matches the condition under which bcm_enet_probe() enables the clock. The
patch has a Fixes: tag for commit 7e697ce99ceb and is marked for stable.

> A clk_prepare_enable(priv->phy_clk) call was specified within an if branch
> in the implementation of the function “bcm_enet_probe” while
> a clk_disable_unprepare(priv->phy_clk) call was unconditionally performed
> in the implementation of the function “bcm_enet_remove”.
> Move this clk_disable_unprepare() call into a corresponding if branch.
>
> Fixes: 7e697ce99ceb09538cdc1dfa9ebb3db60236b0a7 ("bcm63xx_enet: use managed functions for clock/ioremap")
> Cc: stable@vger.kernel.org

[Severity: Medium]
Is the unconditional call actually unbalanced?

bcm_enet_probe() only sets priv->phy_clk inside the branch that also
enables it. If devm_clk_get() fails, it resets the pointer to NULL:

	if (priv->has_phy && !priv->use_external_mii) {
		/* using internal PHY, enable clock */
		priv->phy_clk = devm_clk_get(&pdev->dev, "ephy");
		if (IS_ERR(priv->phy_clk)) {
			ret = PTR_ERR(priv->phy_clk);
			priv->phy_clk = NULL;
			goto out_disable_clk_mac;
		}
		ret = clk_prepare_enable(priv->phy_clk);
		...
	}

In every other case phy_clk stays NULL, because the netdev priv area is
zero-allocated.

BCM63XX_ENET depends on BCM63XX, which uses the legacy clock code in
arch/mips/bcm63xx/clk.c. Its clk_disable() returns early for NULL:

arch/mips/bcm63xx/clk.c:clk_disable() {
	if (!clk)
		return;
	...
}

clk_unprepare() is the inline stub in include/linux/clk.h, and it only
calls might_sleep(). So the old unconditional call did nothing whenever
the clock had not been enabled.

This looks intentional. Commit 4e78e5c5d881 ("bcm63xx_enet: drop unneeded
NULL phy_clk check") removed the earlier guard because "clk_disable and
clk_unprepare are NULL-safe".

The Fixes: target also doesn't seem to match. After 7e697ce99ceb,
bcm_enet_remove() still had the guard:

	if (priv->phy_clk)
		clk_disable_unprepare(priv->phy_clk);

Nothing changes after the later patch in the series ("bcm63xx_enet: Use
devm_clk_get_enabled() in two probe functions") either.

This patch doesn't change runtime behavior. Should the Fixes: and Cc:
stable tags be dropped, and the change described as a cleanup instead of
a fix?

> diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
> index f6595fdc888d1..cc9a5cd2a2a3f 100644
> --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
> +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
> @@ -1915,6 +1915,9 @@ static void bcm_enet_remove(struct platform_device *pdev)
>  	enet_writel(priv, 0, ENET_MIISC_REG);
>  
>  	if (priv->has_phy) {
> +		if (!priv->use_external_mii)
> +			clk_disable_unprepare(priv->phy_clk);
> +
>  		mdiobus_unregister(priv->mii_bus);
>  		mdiobus_free(priv->mii_bus);

[Severity: Low]
Was it intended to move the EPHY clock disable ahead of
mdiobus_unregister() and mdiobus_free()?

Probe enables mac_clk, then phy_clk, and then registers the MDIO bus.
The probe error path in bcm_enet_probe() still undoes these in reverse
order:

out_unregister_mdio:
	if (priv->mii_bus)
		mdiobus_unregister(priv->mii_bus);

out_free_mdio:
	if (priv->mii_bus)
		mdiobus_free(priv->mii_bus);

out_uninit_hw:
	/* turn off mdc clock */
	enet_writel(priv, 0, ENET_MIISC_REG);
	clk_disable_unprepare(priv->phy_clk);

I couldn't find a concrete failure caused by the reorder:

- unregister_netdev() has already disconnected the PHY in ndo_stop.
- MDC is already turned off.
- The bcm63xx internal PHY driver has no .remove callback, so
  mdiobus_unregister() does no MDIO access here.

Still, disabling the clock after the MDIO teardown would keep remove()
as the exact reverse of probe.

> @@ -1927,7 +1930,6 @@ static void bcm_enet_remove(struct platform_device *pdev)
>  	}
>  
>  	/* disable hw block clocks */
> -	clk_disable_unprepare(priv->phy_clk);
>  	clk_disable_unprepare(priv->mac_clk);

[Severity: Low]
If the unconditional call here were a problem, wouldn't the same apply to
the out_uninit_hw label in bcm_enet_probe()? This patch leaves it
unchanged:

out_uninit_hw:
	/* turn off mdc clock */
	enet_writel(priv, 0, ENET_MIISC_REG);
	clk_disable_unprepare(priv->phy_clk);

That label can be reached without phy_clk ever being enabled:

- has_phy == 0 and pd->mii_config() fails.
- An external PHY is used and mdiobus_alloc(), mdiobus_register() or
  register_netdev() fails.

Both calls are NULL-safe, so this has no functional effect. But the two
teardown sites for the same clock now follow different conventions, and
the later devm_clk_get_enabled() patch keeps the unconditional call in
out_uninit_hw.

Should the remove-side change be dropped, or should both sites be
handled the same way?

>  
>  	free_netdev(dev);

[Severity: High]
This is a pre-existing issue, but it is in the same probe/remove pair.
In bcm_enet_probe(), when has_phy == 0 and pd->mii_config(dev, 1, ...)
fails:

		if (pd && pd->mii_config &&
		    pd->mii_config(dev, 1, bcm_enet_mdio_read_mii,
				   bcm_enet_mdio_write_mii)) {
			dev_err(&pdev->dev, "unable to configure mdio bus\n");
			goto out_uninit_hw;
		}

ret is not set on this path. Its last value came from
clk_prepare_enable(priv->mac_clk), which is 0. After the later patch in
the series it comes from bcm_enet_change_mtu(), also 0. So probe calls
free_netdev() and returns 0 without ever calling platform_set_drvdata().

On unbind or module removal, bcm_enet_remove() then runs with
dev == NULL:

	dev = platform_get_drvdata(pdev);
	priv = netdev_priv(dev);
	unregister_netdev(dev);

Can this oops in unregister_netdev(NULL)->rtnl_net_dev_lock()->dev_net()?

No in-tree board file sets mii_config, so this path needs out-of-tree
platform code.

Should ret be set to the return value of mii_config(), or to a negative
errno, before the goto?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/0302adc3-dbf2-4e62-ac9b-8923ac285506%40web.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-28 14:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 14:01 [PATCH v2 2/2] bcm63xx_enet: Adjustments for clock management Markus Elfring
2026-11-27 14:03 ` [PATCH net v2 1/2] bcm63xx_enet: Prevent unbalanced clk_disable_unprepare() call in bcm_enet_remove() Markus Elfring
2026-11-27 14:14   ` netdev-bot+sinfo
2026-11-27 14:26   ` Jonas Gorski
2026-11-27 14:33     ` [v2 " Markus Elfring
2026-11-28 14:31   ` [PATCH net v2 " netdev-bot+sashiko
2026-11-27 14:07 ` [PATCH net v2 2/2] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox