From 69bbb4fe7062440c86c4a104b315cfd0da31fa70 Mon Sep 17 00:00:00 2001 From: Scott Long Date: Thu, 31 Mar 2005 17:16:40 +0000 Subject: [PATCH] If resource allocation fails, we could wind up freeing the cdev without it being allocated. Add a simple check for this. Submitted by: yongari --- sys/dev/ti/if_ti.c | 3 ++- sys/pci/if_ti.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c index 56e2207e6cdc..86cea7c74750 100644 --- a/sys/dev/ti/if_ti.c +++ b/sys/dev/ti/if_ti.c @@ -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; diff --git a/sys/pci/if_ti.c b/sys/pci/if_ti.c index 56e2207e6cdc..86cea7c74750 100644 --- a/sys/pci/if_ti.c +++ b/sys/pci/if_ti.c @@ -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;