[PATCH] net: enetc: unregister mdiobus

Michael Walle michael at walle.cc
Tue May 31 18:36:16 CEST 2022


If the device fails to probe - for example, when there is no
ethaddr set - then the private data is automatically freed
but the mdiobus remains registered.

Fixes: 1e354cb39314 ("drivers: net: fsl_enetc: register internal MDIO bus")
Signed-off-by: Michael Walle <michael at walle.cc>
---
This actually causes the kontron sl28 board (variant 2) to oops
when no ethaddr is set. It would be good if it still makes it
into the next release.

That miiphy_get_dev_by_name() hack is actually borrowed from
the handling in the driver. It should probably be converted
to a proper flag ENETC_IMDIO_REGISTERED or something like
that. But that is beyond the scope of this patch.

 drivers/net/fsl_enetc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
index 9b97a03ccb..cd4c2c29a6 100644
--- a/drivers/net/fsl_enetc.c
+++ b/drivers/net/fsl_enetc.c
@@ -361,6 +361,9 @@ static int enetc_remove(struct udevice *dev)
 {
 	struct enetc_priv *priv = dev_get_priv(dev);
 
+	if (miiphy_get_dev_by_name(priv->imdio.name))
+		mdio_unregister(&priv->imdio);
+
 	free(priv->enetc_txbd);
 	free(priv->enetc_rxbd);
 
-- 
2.30.2



More information about the U-Boot mailing list