Fix "struct ifnet" leak if attach() fails in the middle.

This commit is contained in:
ru 2005-09-16 12:49:06 +00:00
parent a3b89924c1
commit 2bc1b3a583
5 changed files with 12 additions and 3 deletions

View File

@ -152,12 +152,14 @@ oltr_attach(device_t dev)
RF_ACTIVE | RF_SHAREABLE : RF_ACTIVE);
if (sc->irq_res == NULL) {
device_printf(dev, "couldn't map interrupt\n");
if_free(ifp);
return (-1);
}
if (bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, oltr_intr,
sc, &sc-> oltr_intrhand)) {
device_printf(dev, "couldn't setup interrupt\n");
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res);
if_free(ifp);
return (-1);
}

View File

@ -743,6 +743,7 @@ fe_attach (device_t dev)
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
fe_intr, sc, &sc->irq_handle);
if (error) {
if_free(ifp);
fe_release_resource(dev);
return ENXIO;
}

View File

@ -212,6 +212,9 @@ lnc_release_resources(device_t dev)
}
bus_dma_tag_destroy(sc->dmat);
}
if (sc->ifp)
if_free(sc->ifp);
}
/*
@ -897,7 +900,6 @@ lnc_detach_common(device_t dev) {
int s = splimp();
ether_ifdetach(sc->ifp);
if_free(sc->ifp);
lnc_stop(sc);
lnc_release_resources(dev);

View File

@ -560,9 +560,11 @@ nve_detach(device_t dev)
if (device_is_attached(dev)) {
nve_stop(sc);
ether_ifdetach(ifp);
if_free(ifp);
}
if (ifp)
if_free(ifp);
if (sc->miibus)
device_delete_child(dev, sc->miibus);
bus_generic_detach(dev);

View File

@ -477,7 +477,6 @@ patm_detach(device_t dev)
mtx_unlock(&sc->mtx);
atm_ifdetach(sc->ifp);
if_free(sc->ifp);
patm_destroy(sc);
@ -562,6 +561,9 @@ patm_destroy(struct patm_softc *sc)
cv_destroy(&sc->vcc_cv);
mtx_destroy(&sc->tst_lock);
mtx_destroy(&sc->mtx);
if (sc->ifp != NULL)
if_free(sc->ifp);
}
/*