Date: Wed, 7 May 2025 04:22:39 GMT From: Adrian Chadd <adrian@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 68e73f03655c - main - sys: don't panic on ifm_status being NULL Message-ID: <202505070422.5474MdGJ054897@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=68e73f03655c308442a8354ee2c040df23f234b6 commit 68e73f03655c308442a8354ee2c040df23f234b6 Author: Adrian Chadd <adrian@FreeBSD.org> AuthorDate: 2025-05-03 15:41:56 +0000 Commit: Adrian Chadd <adrian@FreeBSD.org> CommitDate: 2025-05-07 04:22:18 +0000 sys: don't panic on ifm_status being NULL Some ethernet drivers that use miibus aren't probe/attaching the miibus early enough for the ifioctl path to correctly run without panicing. Although yes, the drivers do need fixing, this stops them from immediately panicing the kernel when they're loaded. PR: kern/286530 Differential Revision: https://reviews.freebsd.org/D50136 Reviewed by: jhb --- sys/net/if_media.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sys/net/if_media.c b/sys/net/if_media.c index 0cc88a0929e9..bdf9f8ad20c4 100644 --- a/sys/net/if_media.c +++ b/sys/net/if_media.c @@ -59,6 +59,7 @@ #include <sys/sysctl.h> #include <net/if.h> +#include <net/if_var.h> /* for if_printf() */ #include <net/if_media.h> /* @@ -290,6 +291,22 @@ ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, struct ifmedia *ifm, } ifmr->ifm_mask = ifm->ifm_mask; ifmr->ifm_status = 0; + + /* + * Don't panic if ifm_status isn't yet setup due to + * driver/miibus probe ordering. This can happen if + * a kldload'ed driver doesn't set the module order + * to setup miibus early enough. + * + * See kern/286530 for more information. + */ + if (ifm->ifm_status == NULL) { + if_printf(ifp, + "%s: ifm_status is NULL; please fix miibus/driver" + " order\n", + __func__); + return (EDOOFUS); + } (*ifm->ifm_status)(ifp, ifmr); /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202505070422.5474MdGJ054897>