In device detach don't access ifnet structure unless device is

attached. This fixes NULL pointer dereference when polling(9) is
active and unsupported hardware is detected in device attach.
This commit is contained in:
yongari 2008-07-02 06:41:46 +00:00
parent 7238fff022
commit b32906b68f

View File

@ -1391,12 +1391,12 @@ re_detach(dev)
ifp = sc->rl_ifp;
KASSERT(mtx_initialized(&sc->rl_mtx), ("re mutex not initialized"));
#ifdef DEVICE_POLLING
if (ifp->if_capenable & IFCAP_POLLING)
ether_poll_deregister(ifp);
#endif
/* These should only be active if attach succeeded */
if (device_is_attached(dev)) {
#ifdef DEVICE_POLLING
if (ifp->if_capenable & IFCAP_POLLING)
ether_poll_deregister(ifp);
#endif
RL_LOCK(sc);
#if 0
sc->suspended = 1;