If resource allocation fails, we could wind up freeing the cdev without it

being allocated.  Add a simple check for this.

Submitted by: yongari
This commit is contained in:
Scott Long 2005-03-31 17:16:40 +00:00
parent fe234894e5
commit 69bbb4fe70
2 changed files with 4 additions and 2 deletions

View File

@ -2311,7 +2311,8 @@ ti_detach(dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
destroy_dev(sc->dev);
if (sc->dev)
destroy_dev(sc->dev);
KASSERT(mtx_initialized(&sc->ti_mtx), ("ti mutex not initialized"));
TI_LOCK(sc);
ifp = &sc->arpcom.ac_if;

View File

@ -2311,7 +2311,8 @@ ti_detach(dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
destroy_dev(sc->dev);
if (sc->dev)
destroy_dev(sc->dev);
KASSERT(mtx_initialized(&sc->ti_mtx), ("ti mutex not initialized"));
TI_LOCK(sc);
ifp = &sc->arpcom.ac_if;