tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
protect pmf from network drivers that don't provide if_stop
Folks,
I turned up a fix I had put into my source tree a while back, I think at
the time the wireless driver (urtwn IIRC) did not set an entry for
if_stop. This resulted in a kernel panic if you tried to sleep the
machine pmf_class_network_suspend would try to call a null if_stop.
I crafted the following to preserve my sanity, ok to commit?
Index: kern_pmf.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_pmf.c,v
retrieving revision 1.45
diff -u -r1.45 kern_pmf.c
--- kern_pmf.c 11 Jun 2020 02:30:21 -0000 1.45
+++ kern_pmf.c 29 Jun 2021 01:27:01 -0000
@@ -892,11 +892,18 @@
struct ifnet *ifp = device_pmf_class_private(dev);
int s;
- s = splnet();
- IFNET_LOCK(ifp);
- (*ifp->if_stop)(ifp, 0);
- IFNET_UNLOCK(ifp);
- splx(s);
+ if (ifp == NULL)
+ return true;
+
+ if ((*ifp->if_stop) == NULL)
+ printf("device %s has no if_stop\n", ifp->if_xname);
+ else {
+ s = splnet();
+ IFNET_LOCK(ifp);
+ (*ifp->if_stop)(ifp, 0);
+ IFNET_UNLOCK(ifp);
+ splx(s);
+ }
return true;
}
--
Brett Lymn
--
Sent from my NetBSD device.
"We are were wolves",
"You mean werewolves?",
"No we were wolves, now we are something else entirely",
"Oh"
Home |
Main Index |
Thread Index |
Old Index