The branch stable/13 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=baed1f130ab1ca0e553f2cb031f3cfd040ba3cfb
commit baed1f130ab1ca0e553f2cb031f3cfd040ba3cfb Author: Kristof Provost <[email protected]> AuthorDate: 2025-06-12 16:53:33 +0000 Commit: Zhenlei Huang <[email protected]> CommitDate: 2026-02-26 14:17:22 +0000 qlnx: fix panic at startup While attaching the qlnx driver we can end up trying to call ifmedia functions before those are set up (through ether_ifattach() -> rtnl_handle_ifattach() -> dump_iface() -> get_operstate_ether() -> ifmedia_ioctl()). Postpone the ether_ifattach() until after the ifmedia setup. Reviewed by: markj,zlei Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D50819 MFC note: qlnxe(4) does not exhibit panic at startup on stable/13, but there's a small windows that the setup of ifmedia has not been done but other threads try to access the ifmedia, since the ifnet is public visible on ether_ifattach(). Postpone ether_ifattach() until after the ifmedia setup to prevent that. (cherry picked from commit 4f7473d18a62077a218ac00817bae09a95b8cbcb) (cherry picked from commit 8ef7ad95e9156bea689274c9d57fc961b203efe2) --- sys/dev/qlnx/qlnxe/qlnx_os.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/qlnx/qlnxe/qlnx_os.c b/sys/dev/qlnx/qlnxe/qlnx_os.c index 96a5e9e7e269..2586539617dd 100644 --- a/sys/dev/qlnx/qlnxe/qlnx_os.c +++ b/sys/dev/qlnx/qlnxe/qlnx_os.c @@ -2387,9 +2387,6 @@ qlnx_init_ifnet(device_t dev, qlnx_host_t *ha) ha->primary_mac[5] = (rnd >> 16) & 0xFF; } - ether_ifattach(ifp, ha->primary_mac); - bcopy(IF_LLADDR(ha->ifp), ha->primary_mac, ETHER_ADDR_LEN); - ifp->if_capabilities = IFCAP_HWCSUM; ifp->if_capabilities |= IFCAP_JUMBO_MTU; @@ -2442,6 +2439,9 @@ qlnx_init_ifnet(device_t dev, qlnx_host_t *ha) ifmedia_set(&ha->media, (IFM_ETHER | IFM_AUTO)); + ether_ifattach(ifp, ha->primary_mac); + bcopy(IF_LLADDR(ha->ifp), ha->primary_mac, ETHER_ADDR_LEN); + QL_DPRINT2(ha, "exit\n"); return;
