]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: fec-mxc: prevent crash if no MAC address is set
authorMarkus Niebel <Markus.Niebel@ew.tq-group.com>
Fri, 21 Nov 2025 17:34:42 +0000 (18:34 +0100)
committerFabio Estevam <festevam@nabladev.com>
Sat, 29 Nov 2025 17:42:26 +0000 (14:42 -0300)
If no MAC address can be found (either in ROM, device tree or env),
the post_probe of an ethernet device will fail and therefore
the device cannot be instantiated.

The DM_ETH_PHY (eth-phy-uclass) use case must not be mixed with
using CONFIG_FEC_MXC_MDIO_BASE.

This prevents following error for MAC not fused, no eth[1]addr
env is present and providing a random MAC is disabled:

Net:
Error: ethernet@5b040000 address not set.

Error: ethernet@5b040000 address not set.
FEC: can't find phy-handle
"Error" handler, esr 0xbf000002
elr: 000000008004e4b8 lr : 000000008004e4b4 (reloc)
elr: 00000000bfe984b8 lr : 00000000bfe984b4
x0 : 0000000000000000 x1 : 0000000000000020
x2 : 00000000bbe61e50 x3 : 00000000bbe6e1a0
x4 : 0000000000000020 x5 : 0000000000000020
x6 : 000000000000000a x7 : 0000000000000000
x8 : 0000000000000000 x9 : 0000000000000008
x10: 00000000ffffffd8 x11: 0000000000000006
x12: 000000000001869f x13: 0000000000002c50
x14: 0000000000000000 x15: 00000000ffffffff
x16: 0000000000000000 x17: 0000000000000000
x18: 00000000bbe61d98 x19: 00000000bbe4fa68
x20: 00000000bbe78c10 x21: 00000000bbe6e460
x22: 00000000bbe78c10 x23: 00000000bbe91780
x24: 00000000bbe6e510 x25: 00000000000001f8
x26: 00000000ffff8000 x27: 0000000000000000
x28: 0000000000000000 x29: 00000000bbe4fa10

Code: f900003f 9100a3a1 97ffff6e 35000100 (f94017a1)
Resetting CPU ...

Signed-off-by: Markus Niebel <Markus.Niebel@ew.tq-group.com>
Signed-off-by: Alexander Feilke <alexander.feilke@ew.tq-group.com>
drivers/net/fec_mxc.c

index 471e3de44a6822bc5e4e113198ce1ec416fedca6..629def541ae8b0db5c971b8b88f547c78eca9e77 100644 (file)
@@ -1364,17 +1364,18 @@ static int fecmxc_probe(struct udevice *dev)
 
 #ifdef CONFIG_DM_ETH_PHY
        bus = eth_phy_get_mdio_bus(dev);
-#endif
+       if (!bus)
+               bus = fec_get_miibus(dev, (ulong)priv->eth, dev_seq(dev));
+#else
 
-       if (!bus) {
-               dm_mii_bus = false;
+       dm_mii_bus = false;
 #ifdef CONFIG_FEC_MXC_MDIO_BASE
-               bus = fec_get_miibus(dev, (ulong)CONFIG_FEC_MXC_MDIO_BASE,
-                                    dev_seq(dev));
+       bus = fec_get_miibus(dev, (ulong)CONFIG_FEC_MXC_MDIO_BASE, dev_seq(dev));
 #else
-               bus = fec_get_miibus(dev, (ulong)priv->eth, dev_seq(dev));
+       bus = fec_get_miibus(dev, (ulong)priv->eth, dev_seq(dev));
 #endif
-       }
+
+#endif /* CONFIG_DM_ETH_PHY */
        if (!bus) {
                ret = -ENOMEM;
                goto err_mii;