diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2006-05-22 20:35:13 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2006-05-22 20:35:13 +0000 |
commit | 657c3498f0f1f12424b08b44ee1ab824bc20ba62 (patch) | |
tree | 6059bbe140fff90fbc52e205a78ecb62c6ecad0d /sys/dev | |
parent | 015937de55f300730d284d2cf72704203aad00eb (diff) |
Attach routines can fail before calling *hook_establish(), and they
often rely on the detach routine for cleanup. So be consistant and
careful by checking for a NULL hook before calling *hook_disestablish
in detach routines.
ok mickey@ brad@ dlg@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/cardbus/if_re_cardbus.c | 8 | ||||
-rw-r--r-- | sys/dev/ic/aic79xx_openbsd.c | 5 | ||||
-rw-r--r-- | sys/dev/ic/an.c | 5 | ||||
-rw-r--r-- | sys/dev/ic/ath.c | 8 | ||||
-rw-r--r-- | sys/dev/ic/atw.c | 8 | ||||
-rw-r--r-- | sys/dev/ic/dc.c | 8 | ||||
-rw-r--r-- | sys/dev/ic/fxp.c | 8 | ||||
-rw-r--r-- | sys/dev/ic/if_wi.c | 7 | ||||
-rw-r--r-- | sys/dev/ic/rtl81x9.c | 8 | ||||
-rw-r--r-- | sys/dev/ic/xl.c | 8 | ||||
-rw-r--r-- | sys/dev/isa/if_ed.c | 5 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_ray.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/if_aue.c | 5 | ||||
-rw-r--r-- | sys/dev/usb/uhci.c | 8 |
14 files changed, 61 insertions, 38 deletions
diff --git a/sys/dev/cardbus/if_re_cardbus.c b/sys/dev/cardbus/if_re_cardbus.c index 424d4e2bd99..93b4cd0e8e8 100644 --- a/sys/dev/cardbus/if_re_cardbus.c +++ b/sys/dev/cardbus/if_re_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_re_cardbus.c,v 1.2 2005/05/16 01:36:25 brad Exp $ */ +/* $OpenBSD: if_re_cardbus.c,v 1.3 2006/05/22 20:35:12 krw Exp $ */ /* * Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org> @@ -260,8 +260,10 @@ re_cardbus_detach(struct device *self, int flags) if_detach(ifp); /* No more hooks */ - shutdownhook_disestablish(sc->sc_sdhook); - powerhook_disestablish(sc->sc_pwrhook); + if (sc->sc_sdhook != NULL) + shutdownhook_disestablish(sc->sc_sdhook); + if (sc->sc_pwrhook != NULL) + powerhook_disestablish(sc->sc_pwrhook); /* Disable interrupts */ if (csc->sc_ih != NULL) diff --git a/sys/dev/ic/aic79xx_openbsd.c b/sys/dev/ic/aic79xx_openbsd.c index c32948cd517..dae58bc9e3c 100644 --- a/sys/dev/ic/aic79xx_openbsd.c +++ b/sys/dev/ic/aic79xx_openbsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aic79xx_openbsd.c,v 1.24 2006/03/04 14:20:37 krw Exp $ */ +/* $OpenBSD: aic79xx_openbsd.c,v 1.25 2006/05/22 20:35:12 krw Exp $ */ /* * Copyright (c) 2004 Milos Urbanek, Kenneth R. Westerback & Marco Peereboom @@ -639,7 +639,8 @@ ahd_detach(struct device *self, int flags) if (ahd->sc_child != NULL) rv = config_detach((void *)ahd->sc_child, flags); - shutdownhook_disestablish(ahd->shutdown_hook); + if (ahd->shutdown_hook != NULL) + shutdownhook_disestablish(ahd->shutdown_hook); ahd_free(ahd); diff --git a/sys/dev/ic/an.c b/sys/dev/ic/an.c index 0fea39c67fb..7f5f47b3963 100644 --- a/sys/dev/ic/an.c +++ b/sys/dev/ic/an.c @@ -1,4 +1,4 @@ -/* $OpenBSD: an.c,v 1.50 2006/04/05 14:28:20 kurt Exp $ */ +/* $OpenBSD: an.c,v 1.51 2006/05/22 20:35:12 krw Exp $ */ /* $NetBSD: an.c,v 1.34 2005/06/20 02:49:18 atatat Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -1675,7 +1675,8 @@ an_detach(struct an_softc *sc) ifmedia_delete_instance(&sc->sc_ic.ic_media, IFM_INST_ANY); ieee80211_ifdetach(ifp); if_detach(ifp); - shutdownhook_disestablish(sc->sc_sdhook); + if (sc->sc_sdhook != NULL) + shutdownhook_disestablish(sc->sc_sdhook); splx(s); return 0; } diff --git a/sys/dev/ic/ath.c b/sys/dev/ic/ath.c index bb1f4090432..16f5587cbf6 100644 --- a/sys/dev/ic/ath.c +++ b/sys/dev/ic/ath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ath.c,v 1.49 2006/05/08 18:32:11 pedro Exp $ */ +/* $OpenBSD: ath.c,v 1.50 2006/05/22 20:35:12 krw Exp $ */ /* $NetBSD: ath.c,v 1.37 2004/08/18 21:59:39 dyoung Exp $ */ /*- @@ -459,8 +459,10 @@ ath_detach(struct ath_softc *sc, int flags) if_detach(ifp); splx(s); - powerhook_disestablish(sc->sc_powerhook); - shutdownhook_disestablish(sc->sc_sdhook); + if (sc->sc_powerhook != NULL) + powerhook_disestablish(sc->sc_powerhook); + if (sc->sc_sdhook != NULL) + shutdownhook_disestablish(sc->sc_sdhook); #ifdef __FreeBSD__ ATH_TXBUF_LOCK_DESTROY(sc); ATH_TXQ_LOCK_DESTROY(sc); diff --git a/sys/dev/ic/atw.c b/sys/dev/ic/atw.c index 0ee9e7938f1..3a6ee80f30b 100644 --- a/sys/dev/ic/atw.c +++ b/sys/dev/ic/atw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atw.c,v 1.45 2006/03/25 22:41:42 djm Exp $ */ +/* $OpenBSD: atw.c,v 1.46 2006/05/22 20:35:12 krw Exp $ */ /* $NetBSD: atw.c,v 1.69 2004/07/23 07:07:55 dyoung Exp $ */ /*- @@ -2775,8 +2775,10 @@ atw_detach(struct atw_softc *sc) sizeof(struct atw_control_data)); bus_dmamem_free(sc->sc_dmat, &sc->sc_cdseg, sc->sc_cdnseg); - shutdownhook_disestablish(sc->sc_sdhook); - powerhook_disestablish(sc->sc_powerhook); + if (sc->sc_sdhook != NULL) + shutdownhook_disestablish(sc->sc_sdhook); + if (sc->sc_powerhook != NULL) + powerhook_disestablish(sc->sc_powerhook); if (sc->sc_srom) free(sc->sc_srom, M_DEVBUF); diff --git a/sys/dev/ic/dc.c b/sys/dev/ic/dc.c index a50371210fa..7c53a041857 100644 --- a/sys/dev/ic/dc.c +++ b/sys/dev/ic/dc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dc.c,v 1.94 2006/05/07 03:56:25 brad Exp $ */ +/* $OpenBSD: dc.c,v 1.95 2006/05/22 20:35:12 krw Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -1876,8 +1876,10 @@ dc_detach(sc) ether_ifdetach(ifp); if_detach(ifp); - shutdownhook_disestablish(sc->sc_dhook); - powerhook_disestablish(sc->sc_pwrhook); + if (sc->sc_dhook != NULL) + shutdownhook_disestablish(sc->sc_dhook); + if (sc->sc_pwrhook != NULL) + powerhook_disestablish(sc->sc_pwrhook); return (0); } diff --git a/sys/dev/ic/fxp.c b/sys/dev/ic/fxp.c index 0873810805b..024d67dd315 100644 --- a/sys/dev/ic/fxp.c +++ b/sys/dev/ic/fxp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fxp.c,v 1.77 2006/03/25 22:41:42 djm Exp $ */ +/* $OpenBSD: fxp.c,v 1.78 2006/05/22 20:35:12 krw Exp $ */ /* $NetBSD: if_fxp.c,v 1.2 1997/06/05 02:01:55 thorpej Exp $ */ /* @@ -578,8 +578,10 @@ fxp_detach(sc) ether_ifdetach(ifp); if_detach(ifp); - shutdownhook_disestablish(sc->sc_sdhook); - powerhook_disestablish(sc->sc_powerhook); + if (sc->sc_sdhook != NULL) + shutdownhook_disestablish(sc->sc_sdhook); + if (sc->sc_powerhook != NULL) + powerhook_disestablish(sc->sc_powerhook); return (0); } diff --git a/sys/dev/ic/if_wi.c b/sys/dev/ic/if_wi.c index 049ef897ab3..9f9f5b52bf2 100644 --- a/sys/dev/ic/if_wi.c +++ b/sys/dev/ic/if_wi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi.c,v 1.128 2006/04/10 00:58:52 deraadt Exp $ */ +/* $OpenBSD: if_wi.c,v 1.129 2006/05/22 20:35:12 krw Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -127,7 +127,7 @@ u_int32_t widebug = WIDEBUG; #if !defined(lint) && !defined(__OpenBSD__) static const char rcsid[] = - "$OpenBSD: if_wi.c,v 1.128 2006/04/10 00:58:52 deraadt Exp $"; + "$OpenBSD: if_wi.c,v 1.129 2006/05/22 20:35:12 krw Exp $"; #endif /* lint */ #ifdef foo @@ -2473,7 +2473,8 @@ wi_detach(struct wi_softc *sc) if (sc->wi_flags & WI_FLAGS_ATTACHED) { sc->wi_flags &= ~WI_FLAGS_ATTACHED; - shutdownhook_disestablish(sc->sc_sdhook); + if (sc->sc_sdhook != NULL) + shutdownhook_disestablish(sc->sc_sdhook); } } diff --git a/sys/dev/ic/rtl81x9.c b/sys/dev/ic/rtl81x9.c index 874073ea00d..58a014644c9 100644 --- a/sys/dev/ic/rtl81x9.c +++ b/sys/dev/ic/rtl81x9.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtl81x9.c,v 1.49 2006/04/20 20:31:12 miod Exp $ */ +/* $OpenBSD: rtl81x9.c,v 1.50 2006/05/22 20:35:12 krw Exp $ */ /* * Copyright (c) 1997, 1998 @@ -1360,8 +1360,10 @@ rl_detach(sc) ether_ifdetach(ifp); if_detach(ifp); - shutdownhook_disestablish(sc->sc_sdhook); - powerhook_disestablish(sc->sc_pwrhook); + if (sc->sc_sdhook != NULL) + shutdownhook_disestablish(sc->sc_sdhook); + if (sc->sc_pwrhook != NULL) + powerhook_disestablish(sc->sc_pwrhook); return (0); } diff --git a/sys/dev/ic/xl.c b/sys/dev/ic/xl.c index cf6223078dd..fa923644f2b 100644 --- a/sys/dev/ic/xl.c +++ b/sys/dev/ic/xl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xl.c,v 1.72 2006/03/25 22:41:43 djm Exp $ */ +/* $OpenBSD: xl.c,v 1.73 2006/05/22 20:35:12 krw Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -2863,8 +2863,10 @@ xl_detach(sc) ether_ifdetach(ifp); if_detach(ifp); - shutdownhook_disestablish(sc->sc_sdhook); - powerhook_disestablish(sc->sc_pwrhook); + if (sc->sc_sdhook != NULL) + shutdownhook_disestablish(sc->sc_sdhook); + if (sc->sc_pwrhook != NULL) + powerhook_disestablish(sc->sc_pwrhook); return (0); } diff --git a/sys/dev/isa/if_ed.c b/sys/dev/isa/if_ed.c index 9b65b34ac00..8a5100dc7b0 100644 --- a/sys/dev/isa/if_ed.c +++ b/sys/dev/isa/if_ed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ed.c,v 1.56 2006/03/25 22:41:44 djm Exp $ */ +/* $OpenBSD: if_ed.c,v 1.57 2006/05/22 20:35:12 krw Exp $ */ /* $NetBSD: if_ed.c,v 1.105 1996/10/21 22:40:45 thorpej Exp $ */ /* @@ -282,7 +282,8 @@ ed_remove(pc_link,self) struct ifnet *ifp = &sc->sc_arpcom.ac_if; if_down(ifp); edstop(sc); - shutdownhook_disestablish(sc->sc_sh); + if (sc->sc_sh != NULL) + shutdownhook_disestablish(sc->sc_sh); ifp->if_flags &= ~(IFF_RUNNING|IFF_UP); sc->spec_flags |= ED_NOTPRESENT; isa_intr_disestablish(sc->sc_ic, sc->sc_ih); diff --git a/sys/dev/pcmcia/if_ray.c b/sys/dev/pcmcia/if_ray.c index 1f7acae9c00..bf5e1a4712b 100644 --- a/sys/dev/pcmcia/if_ray.c +++ b/sys/dev/pcmcia/if_ray.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ray.c,v 1.31 2006/03/25 22:41:46 djm Exp $ */ +/* $OpenBSD: if_ray.c,v 1.32 2006/05/22 20:35:12 krw Exp $ */ /* $NetBSD: if_ray.c,v 1.21 2000/07/05 02:35:54 onoe Exp $ */ /* @@ -717,8 +717,10 @@ ray_detach(self, flags) ether_ifdetach(ifp); if_detach(ifp); - powerhook_disestablish(sc->sc_pwrhook); - shutdownhook_disestablish(sc->sc_sdhook); + if (sc->sc_pwrhook != NULL) + powerhook_disestablish(sc->sc_pwrhook); + if (sc->sc_sdhook != NULL) + shutdownhook_disestablish(sc->sc_sdhook); return (0); } diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c index 3b1404efbcd..4f5f15f669f 100644 --- a/sys/dev/usb/if_aue.c +++ b/sys/dev/usb/if_aue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_aue.c,v 1.46 2006/05/18 16:46:05 jolan Exp $ */ +/* $OpenBSD: if_aue.c,v 1.47 2006/05/22 20:35:12 krw Exp $ */ /* $NetBSD: if_aue.c,v 1.82 2003/03/05 17:37:36 shiba Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -896,7 +896,8 @@ USB_DETACH(aue) #endif sc->aue_attached = 0; - shutdownhook_disestablish(sc->sc_sdhook); + if (sc->sc_sdhook != NULL) + shutdownhook_disestablish(sc->sc_sdhook); if (--sc->aue_refcnt >= 0) { /* Wait for processes to go away. */ diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index 56304a80022..51d37241129 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhci.c,v 1.43 2006/04/21 07:29:11 jolan Exp $ */ +/* $OpenBSD: uhci.c,v 1.44 2006/05/22 20:35:12 krw Exp $ */ /* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -563,8 +563,10 @@ uhci_detach(struct uhci_softc *sc, int flags) return (rv); #if defined(__NetBSD__) || defined(__OpenBSD__) - powerhook_disestablish(sc->sc_powerhook); - shutdownhook_disestablish(sc->sc_shutdownhook); + if (sc->sc_powerhook != NULL) + powerhook_disestablish(sc->sc_powerhook); + if (sc->sc_shutdownhook != NULL) + shutdownhook_disestablish(sc->sc_shutdownhook); #endif /* Free all xfers associated with this HC. */ |