u-boot/net
Weijie Gao 7e0370f37d miiphy: define mii_devs with LIST_HEAD()
When enabling net console and console multiplexing, a boot crash was
observed using mtk_eth driver with stdin/stdout set to "serial,nc"
in persistent environment:

> CPU:   MediaTek MT7981
> Model: OpenWrt One
> DRAM:  1 GiB
> Core:  35 devices, 15 uclasses, devicetree: separate
> spi-nand: spi_nand spi_nand@0: Winbond SPI NAND was found.
> spi-nand: spi_nand spi_nand@0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
> Loading Environment from UBI... SF: Detected w25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
> mtd: partition "ubi" extends beyond the end of device "spi-nand0" -- size truncated to 0x7f00000
> Read 126976 bytes from volume ubootenv to 000000007f7bf0c0
> Read 126976 bytes from volume ubootenv2 to 000000007f7de100
> OK
> "Synchronous Abort" handler, esr 0x96000004, far 0xeafffffeea000018
> elr: 0000000041e63cd4 lr : 0000000041e1b844 (reloc)
> elr: 000000007ff9ecd4 lr : 000000007ff56844
> x0 : eafffffeea000018 x1 : 000000007fb552e0
> x2 : 00000000000000fe x3 : 0000000000000000

The cause is that "serial,nc" forced the console subsystem to
initialize the ethernet driver before ethernet subsystem
initialization (console_init_r() is called before initr_net()).

During the mtk_eth driver initialization, mdio_register() will be
called, and miiphy_get_dev_by_name() will then be called.

The miiphy_get_dev_by_name() will check the list "mii_devs" to see
if the passed device name exists. However the mii_devs is defined
without initialization:
> static struct list_head mii_devs;
and the actual initialization is done in the following chain:
initr_net -> eth_initialize -> eth_common_init -> miiphy_init
Since initr_net() hasn't be called, iterating over the mii_devs
will access to physical address 0 (mii_devs.next == NULL) and will
cause the crash.

The fix is to define mii_devs using:
> static LIST_HEAD(mii_devs);

As the "current_mii" is defined as a static variable, it will
always be NULL in board_r stage and initializing it will NULL is
unnecessary. So the entire miiphy_init() can be remove.

Signed-off-by: Weijie Gao <hackpascal@gmail.com>
2025-03-04 08:03:47 -06:00
..
lwip net: Kconfig: depend on DM_RNG for WGET_HTTPS 2025-02-12 12:37:24 -06:00
arp.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
arp.h global: Drop common.h inclusion 2023-12-21 08:54:37 -05:00
bootp.c global: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD 2024-10-11 11:44:48 -06:00
bootp.h net: Remove duplicate newlines 2024-07-15 12:12:18 -06:00
cdp.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
cdp.h SPDX: Convert a few files that were missed before 2018-05-10 20:38:35 -04:00
dhcpv6.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
dhcpv6.h net: dhcp6: Fix VCI string 2023-06-14 15:48:45 -04:00
dns.c net: Remove duplicate newlines 2024-07-15 12:12:18 -06:00
dns.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
dsa-uclass.c net: dsa: Fix OF fallback lookup for ports 2023-06-14 18:38:25 +08:00
eth-uclass.c net: eth-uclass: add function eth_start_udev() 2024-10-16 11:11:56 -06:00
eth_bootdev.c net: eth_bootdev_hunt() should not run DHCP 2025-01-05 02:30:48 +01:00
eth_common.c miiphy: define mii_devs with LIST_HEAD() 2025-03-04 08:03:47 -06:00
eth_internal.h net: remove duplicate eth_env_set_enetaddr_by_index() declaration 2024-07-31 17:55:08 -06:00
fastboot_tcp.c net/tcp: improve tcp framework, use better state machine 2024-12-28 11:59:42 -06:00
fastboot_udp.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
Kconfig Prepare v2025.01-rc5 2024-12-25 22:31:04 -06:00
link_local.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
link_local.h global: Drop common.h inclusion 2023-12-21 08:54:37 -05:00
Makefile net: Kconfig: add CONFIG_WGET symbol 2024-11-16 21:35:05 +01:00
mdio-mux-uclass.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
mdio-uclass.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
ndisc.c Fix neighbor discovery ethernet address saving 2025-01-01 14:40:04 -06:00
net-common.c net: wget: let wget_with_dns work with dns disabled 2024-12-04 12:24:37 +01:00
net.c net/net: fix include ordering 2024-12-28 11:59:42 -06:00
net6.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
net_rand.h rng: Introduce SPL_DM_RNG 2024-05-05 11:21:39 -03:00
nfs.c net: Remove duplicate newlines 2024-07-15 12:12:18 -06:00
nfs.h net: Remove duplicate newlines 2024-07-15 12:12:18 -06:00
pcap.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
ping.c net: Do not respond to ICMP_ECHO_REQUEST if we do not have an IP address 2021-01-19 09:15:02 -05:00
ping.h global: Drop common.h inclusion 2023-12-21 08:54:37 -05:00
ping6.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
rarp.c net: Remove duplicate newlines 2024-07-15 12:12:18 -06:00
rarp.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
sntp.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
tcp.c net/tcp: define a fallback value for rcv_wnd size 2024-12-28 11:59:42 -06:00
tftp.c net: tftpput: reset timeout_count when an ACK is received 2025-01-01 14:40:04 -06:00
udp.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
wget.c legacy-net: wget: fix wget_info handling after new tcp legacy stack 2025-02-28 15:26:05 +01:00
wol.c Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet" 2024-05-20 13:35:03 -06:00
wol.h net: Add new wol command - Wake on LAN 2018-07-02 14:14:20 -05:00