From 985e35fdbaafacb128246b9c324b47382c1c525c Mon Sep 17 00:00:00 2001 From: ru Date: Fri, 16 Sep 2005 09:20:58 +0000 Subject: Add missing mtx_destroy() when if_alloc() fails. Add missing if_free() when mii_phy_probe() fails. Put if_free() into the correct #ifdef in detach(). --- sys/dev/usb/if_aue.c | 7 ++++++- sys/dev/usb/if_axe.c | 7 ++++++- sys/dev/usb/if_cdce.c | 2 ++ sys/dev/usb/if_cue.c | 6 +++++- sys/dev/usb/if_kue.c | 6 +++++- sys/dev/usb/if_udav.c | 3 +++ 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c index 5112d7b..4793c4d 100644 --- a/sys/dev/usb/if_aue.c +++ b/sys/dev/usb/if_aue.c @@ -715,6 +715,10 @@ USB_ATTACH(aue) ifp = sc->aue_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { printf("aue%d: can not if_alloc()\n", sc->aue_unit); + AUE_UNLOCK(sc); +#if __FreeBSD_version >= 500000 + mtx_destroy(&sc->aue_mtx); +#endif USB_ATTACH_ERROR_RETURN; } ifp->if_softc = sc; @@ -745,6 +749,7 @@ USB_ATTACH(aue) if (mii_phy_probe(self, &sc->aue_miibus, aue_ifmedia_upd, aue_ifmedia_sts)) { printf("aue%d: MII without any PHY!\n", sc->aue_unit); + if_free(ifp); AUE_UNLOCK(sc); #if __FreeBSD_version >= 500000 mtx_destroy(&sc->aue_mtx); @@ -785,9 +790,9 @@ aue_detach(device_ptr_t dev) untimeout(aue_tick, sc, sc->aue_stat_ch); #if __FreeBSD_version >= 500000 ether_ifdetach(ifp); + if_free(ifp); #else ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); - if_free(ifp); #endif if (sc->aue_ep[AUE_ENDPT_TX] != NULL) diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c index 349c917..65d10c3 100644 --- a/sys/dev/usb/if_axe.c +++ b/sys/dev/usb/if_axe.c @@ -485,6 +485,10 @@ USB_ATTACH(axe) ifp = sc->axe_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { printf("axe%d: can not if_alloc()\n", sc->axe_unit); + AXE_UNLOCK(sc); +#if __FreeBSD_version >= 500000 + mtx_destroy(&sc->axe_mtx); +#endif USB_ATTACH_ERROR_RETURN; } ifp->if_softc = sc; @@ -505,6 +509,7 @@ USB_ATTACH(axe) if (mii_phy_probe(self, &sc->axe_miibus, axe_ifmedia_upd, axe_ifmedia_sts)) { printf("axe%d: MII without any PHY!\n", sc->axe_unit); + if_free(ifp); AXE_UNLOCK(sc); #if __FreeBSD_version >= 500000 mtx_destroy(&sc->axe_mtx); @@ -545,9 +550,9 @@ axe_detach(device_ptr_t dev) untimeout(axe_tick, sc, sc->axe_stat_ch); #if __FreeBSD_version >= 500000 ether_ifdetach(ifp); + if_free(ifp); #else ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); - if_free(ifp); #endif if (sc->axe_ep[AXE_ENDPT_TX] != NULL) diff --git a/sys/dev/usb/if_cdce.c b/sys/dev/usb/if_cdce.c index b44b299..c738272 100644 --- a/sys/dev/usb/if_cdce.c +++ b/sys/dev/usb/if_cdce.c @@ -286,6 +286,8 @@ USB_ATTACH(cdce) ifp = GET_IFP(sc) = if_alloc(IFT_ETHER); if (ifp == NULL) { printf("%s: can not if_alloc()\n", USBDEVNAME(sc->cdce_dev)); + CDCE_UNLOCK(sc); + mtx_destroy(&sc->cdce_mtx); USB_ATTACH_ERROR_RETURN; } ifp->if_softc = sc; diff --git a/sys/dev/usb/if_cue.c b/sys/dev/usb/if_cue.c index e597051..0d6ce71 100644 --- a/sys/dev/usb/if_cue.c +++ b/sys/dev/usb/if_cue.c @@ -505,6 +505,10 @@ USB_ATTACH(cue) ifp = sc->cue_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { printf("cue%d: can not if_alloc()\n", sc->cue_unit); + CUE_UNLOCK(sc); +#if __FreeBSD_version >= 500000 + mtx_destroy(&sc->cue_mtx); +#endif USB_ATTACH_ERROR_RETURN; } ifp->if_softc = sc; @@ -552,9 +556,9 @@ cue_detach(device_ptr_t dev) untimeout(cue_tick, sc, sc->cue_stat_ch); #if __FreeBSD_version >= 500000 ether_ifdetach(ifp); + if_free(ifp); #else ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); - if_free(ifp); #endif if (sc->cue_ep[CUE_ENDPT_TX] != NULL) diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c index f8c9d95..7c5a700 100644 --- a/sys/dev/usb/if_kue.c +++ b/sys/dev/usb/if_kue.c @@ -478,6 +478,10 @@ USB_ATTACH(kue) ifp = sc->kue_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { printf("kue%d: can not if_alloc()\n", sc->kue_unit); + KUE_UNLOCK(sc); +#if __FreeBSD_version >= 500000 + mtx_destroy(&sc->kue_mtx); +#endif USB_ATTACH_ERROR_RETURN; } ifp->if_softc = sc; @@ -526,9 +530,9 @@ kue_detach(device_ptr_t dev) if (ifp != NULL) #if __FreeBSD_version >= 500000 ether_ifdetach(ifp); + if_free(ifp); #else ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); - if_free(ifp); #endif if (sc->kue_ep[KUE_ENDPT_TX] != NULL) diff --git a/sys/dev/usb/if_udav.c b/sys/dev/usb/if_udav.c index 690c9de..cd09046 100644 --- a/sys/dev/usb/if_udav.c +++ b/sys/dev/usb/if_udav.c @@ -378,6 +378,7 @@ USB_ATTACH(udav) splx(s); #elif defined(__FreeBSD__) UDAV_UNLOCK(sc); + mtx_destroy(&sc->sc_mtx); #endif goto bad; } @@ -391,6 +392,7 @@ USB_ATTACH(udav) if (ifp == NULL) { printf("%s: can not if_alloc\n", devname); UDAV_UNLOCK(sc); + mtx_destroy(&sc->sc_mtx); goto bad; } #else @@ -447,6 +449,7 @@ USB_ATTACH(udav) if (mii_phy_probe(self, &sc->sc_miibus, udav_ifmedia_change, udav_ifmedia_status)) { printf("%s: MII without any PHY!\n", USBDEVNAME(sc->sc_dev)); + if_free(ifp); UDAV_UNLOCK(sc); mtx_destroy(&sc->sc_mtx); USB_ATTACH_ERROR_RETURN; -- cgit v1.1