diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index 785182539cce..a11beda48f07 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -380,13 +380,15 @@ ed_detach(device_t dev) struct ifnet *ifp = sc->ifp; ED_ASSERT_UNLOCKED(sc); - ED_LOCK(sc); - if (bus_child_present(dev)) - ed_stop(sc); - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - ED_UNLOCK(sc); - callout_drain(&sc->tick_ch); - ether_ifdetach(ifp); + if (ifp) { + ED_LOCK(sc); + if (bus_child_present(dev)) + ed_stop(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + ED_UNLOCK(sc); + callout_drain(&sc->tick_ch); + ether_ifdetach(ifp); + } bus_teardown_intr(dev, sc->irq_res, sc->irq_handle); ed_release_resources(dev); ED_LOCK_DESTROY(sc); diff --git a/sys/dev/ed/if_ed_pccard.c b/sys/dev/ed/if_ed_pccard.c index 0cd2565d3a72..b09ad63e4564 100644 --- a/sys/dev/ed/if_ed_pccard.c +++ b/sys/dev/ed/if_ed_pccard.c @@ -572,7 +572,7 @@ ed_pccard_attach(device_t dev) ed_pccard_add_modem(dev); return (0); bad: - ed_release_resources(dev); + ed_detach(dev); return (error); }