diff options
| author | riastradh <riastradh@NetBSD.org> | 2021-06-16 00:21:17 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2021-06-16 00:21:17 +0000 |
| commit | bbdda93be2f0bfefe91466b398fe42700a6ea284 (patch) | |
| tree | e75e77046575209dbb21f73d0bc44c61ec0ec6c0 /sys | |
| parent | 5a96957fa793651c8e7093a5a4c2fcae87232af2 (diff) | |
if_attach and if_initialize cannot fail, don't test return value
These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:
https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html
However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:
https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html
So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)
There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.
(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)
Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
Diffstat (limited to 'sys')
49 files changed, 154 insertions, 484 deletions
diff --git a/sys/arch/arm/broadcom/bcm53xx_eth.c b/sys/arch/arm/broadcom/bcm53xx_eth.c index bea0c1c4014..b91892cd60c 100644 --- a/sys/arch/arm/broadcom/bcm53xx_eth.c +++ b/sys/arch/arm/broadcom/bcm53xx_eth.c @@ -35,7 +35,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.40 2020/02/03 08:00:35 skrll Exp $"); +__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.41 2021/06/16 00:21:17 riastradh Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -407,12 +407,7 @@ bcmeth_ccb_attach(device_t parent, device_t self, void *aux) /* * Attach the interface. */ - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - goto fail_5; - } + if_initialize(ifp); ether_ifattach(ifp, sc->sc_enaddr); if_register(ifp); @@ -433,8 +428,6 @@ bcmeth_ccb_attach(device_t parent, device_t self, void *aux) return; -fail_5: - ifmedia_removeall(&sc->sc_media); fail_4: intr_disestablish(sc->sc_ih); fail_3: diff --git a/sys/arch/powerpc/booke/dev/pq3etsec.c b/sys/arch/powerpc/booke/dev/pq3etsec.c index f271960a0ed..49e82d1c693 100644 --- a/sys/arch/powerpc/booke/dev/pq3etsec.c +++ b/sys/arch/powerpc/booke/dev/pq3etsec.c @@ -1,4 +1,4 @@ -/* $NetBSD: pq3etsec.c,v 1.54 2021/04/24 23:36:46 thorpej Exp $ */ +/* $NetBSD: pq3etsec.c,v 1.55 2021/06/16 00:21:18 riastradh Exp $ */ /*- * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.54 2021/04/24 23:36:46 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.55 2021/06/16 00:21:18 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -804,12 +804,7 @@ pq3etsec_attach(device_t parent, device_t self, void *aux) /* * Attach the interface. */ - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - goto fail_10; - } + if_initialize(ifp); pq3etsec_sysctl_setup(NULL, sc); if_attach(ifp); if_deferred_start_init(ifp, NULL); @@ -840,9 +835,6 @@ pq3etsec_attach(device_t parent, device_t self, void *aux) NULL, xname, "mii ticks"); return; -fail_10: - ifmedia_removeall(&mii->mii_media); - mii_detach(mii, sc->sc_phy_addr, MII_OFFSET_ANY); fail_9: softint_disestablish(sc->sc_soft_ih); fail_8: diff --git a/sys/arch/usermode/dev/if_veth.c b/sys/arch/usermode/dev/if_veth.c index a0ccd024bbb..a9488bf9c75 100644 --- a/sys/arch/usermode/dev/if_veth.c +++ b/sys/arch/usermode/dev/if_veth.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_veth.c,v 1.14 2020/02/05 07:18:16 skrll Exp $ */ +/* $NetBSD: if_veth.c,v 1.15 2021/06/16 00:21:18 riastradh Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 1.14 2020/02/05 07:18:16 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 1.15 2021/06/16 00:21:18 riastradh Exp $"); #include <sys/param.h> #include <sys/proc.h> @@ -102,7 +102,6 @@ veth_attach(device_t parent, device_t self, void *opaque) struct veth_softc *sc = device_private(self); struct thunkbus_attach_args *taa = opaque; struct ifnet *ifp = &sc->sc_ec.ec_if; - int rv; sc->sc_dev = self; @@ -138,13 +137,7 @@ veth_attach(device_t parent, device_t self, void *opaque) IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); IFQ_SET_READY(&ifq->if_snd); - rv = if_initialize(ifp); - if (rv != 0) { - aprint_error_dev(self, "if_initialize failed(%d)\n", rv); - thunk_close(sc->sc_tapfd); - pmf_device_deregister(self); - return; /* Error */ - } + if_initialize(ifp); ether_ifattach(ifp, sc->sc_eaddr); if_register(ifp); diff --git a/sys/dev/hyperv/if_hvn.c b/sys/dev/hyperv/if_hvn.c index aa1aa499738..41f8495c4e7 100644 --- a/sys/dev/hyperv/if_hvn.c +++ b/sys/dev/hyperv/if_hvn.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.20 2021/01/29 04:38:49 nonaka Exp $ */ +/* $NetBSD: if_hvn.c,v 1.21 2021/06/16 00:21:18 riastradh Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.20 2021/01/29 04:38:49 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.21 2021/06/16 00:21:18 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -243,7 +243,6 @@ hvn_attach(device_t parent, device_t self, void *aux) struct vmbus_attach_args *aa = aux; struct ifnet *ifp = SC2IFP(sc); uint8_t enaddr[ETHER_ADDR_LEN]; - int error; sc->sc_dev = self; sc->sc_vmbus = (struct vmbus_softc *)device_private(parent); @@ -302,11 +301,7 @@ hvn_attach(device_t parent, device_t self, void *aux) ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL); ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_MANUAL); - error = if_initialize(ifp); - if (error) { - aprint_error_dev(self, "if_initialize failed(%d)\n", error); - goto fail3; - } + if_initialize(ifp); sc->sc_ipq = if_percpuq_create(ifp); if_deferred_start_init(ifp, NULL); diff --git a/sys/dev/ic/an.c b/sys/dev/ic/an.c index 939e2915e54..4804ffca48c 100644 --- a/sys/dev/ic/an.c +++ b/sys/dev/ic/an.c @@ -1,4 +1,4 @@ -/* $NetBSD: an.c,v 1.74 2021/06/11 05:00:41 jdc Exp $ */ +/* $NetBSD: an.c,v 1.75 2021/06/16 00:21:18 riastradh Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.74 2021/06/11 05:00:41 jdc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.75 2021/06/16 00:21:18 riastradh Exp $"); #include <sys/param.h> @@ -315,11 +315,7 @@ an_attach(struct an_softc *sc) /* * Call MI attach routine. */ - rv = if_initialize(ifp); - if (rv != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", rv); - goto fail_2; - } + if_initialize(ifp); ieee80211_ifattach(ic); ifp->if_percpuq = if_percpuq_create(ifp); if_register(ifp); diff --git a/sys/dev/ic/athn.c b/sys/dev/ic/athn.c index b6163dcf5a4..0a5779938c7 100644 --- a/sys/dev/ic/athn.c +++ b/sys/dev/ic/athn.c @@ -1,4 +1,4 @@ -/* $NetBSD: athn.c,v 1.24 2020/11/15 12:33:53 mlelstv Exp $ */ +/* $NetBSD: athn.c,v 1.25 2021/06/16 00:21:18 riastradh Exp $ */ /* $OpenBSD: athn.c,v 1.83 2014/07/22 13:12:11 mpi Exp $ */ /*- @@ -23,7 +23,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.24 2020/11/15 12:33:53 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.25 2021/06/16 00:21:18 riastradh Exp $"); #ifndef _MODULE #include "athn_usb.h" /* for NATHN_USB */ @@ -348,16 +348,7 @@ athn_attach(struct athn_softc *sc) IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - pmf_event_deregister(sc->sc_dev, PMFE_RADIO_OFF, - athn_pmf_wlan_off, false); - callout_destroy(&sc->sc_scan_to); - callout_destroy(&sc->sc_calib_to); - return error; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); diff --git a/sys/dev/ic/atw.c b/sys/dev/ic/atw.c index 4367ee58b9a..c628da6d61f 100644 --- a/sys/dev/ic/atw.c +++ b/sys/dev/ic/atw.c @@ -1,4 +1,4 @@ -/* $NetBSD: atw.c,v 1.170 2020/01/29 14:09:58 thorpej Exp $ */ +/* $NetBSD: atw.c,v 1.171 2021/06/16 00:21:18 riastradh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.170 2020/01/29 14:09:58 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.171 2021/06/16 00:21:18 riastradh Exp $"); #include <sys/param.h> @@ -780,12 +780,7 @@ atw_attach(struct atw_softc *sc) * Call MI attach routines. */ - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - goto fail_5; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); diff --git a/sys/dev/ic/bwfm.c b/sys/dev/ic/bwfm.c index 89c1b08aefa..b42abf3004c 100644 --- a/sys/dev/ic/bwfm.c +++ b/sys/dev/ic/bwfm.c @@ -1,4 +1,4 @@ -/* $NetBSD: bwfm.c,v 1.30 2021/04/13 04:13:52 mrg Exp $ */ +/* $NetBSD: bwfm.c,v 1.31 2021/06/16 00:21:18 riastradh Exp $ */ /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation @@ -422,15 +422,7 @@ bwfm_attach(struct bwfm_softc *sc) IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, DEVNAME(sc), IFNAMSIZ); - error = if_initialize(ifp); - if (error != 0) { - printf("%s: if_initialize failed(%d)\n", DEVNAME(sc), error); - pool_cache_destroy(sc->sc_freetask); - workqueue_destroy(sc->sc_taskq); - - return; /* Error */ - } - + if_initialize(ifp); ieee80211_ifattach(ic); sc->sc_newstate = ic->ic_newstate; ic->ic_newstate = bwfm_newstate; diff --git a/sys/dev/ic/bwi.c b/sys/dev/ic/bwi.c index 32c819de01c..4483d23043c 100644 --- a/sys/dev/ic/bwi.c +++ b/sys/dev/ic/bwi.c @@ -1,4 +1,4 @@ -/* $NetBSD: bwi.c,v 1.37 2020/01/29 14:14:55 thorpej Exp $ */ +/* $NetBSD: bwi.c,v 1.38 2021/06/16 00:21:18 riastradh Exp $ */ /* $OpenBSD: bwi.c,v 1.74 2008/02/25 21:13:30 mglocker Exp $ */ /* @@ -48,7 +48,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bwi.c,v 1.37 2020/01/29 14:14:55 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bwi.c,v 1.38 2021/06/16 00:21:18 riastradh Exp $"); #include <sys/param.h> #include <sys/callout.h> @@ -1021,12 +1021,7 @@ bwi_attach(struct bwi_softc *sc) ic->ic_updateslot = bwi_updateslot; - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - goto fail; - } + if_initialize(ifp); ieee80211_ifattach(ic); ifp->if_percpuq = if_percpuq_create(ifp); if_register(ifp); diff --git a/sys/dev/ic/dwc_gmac.c b/sys/dev/ic/dwc_gmac.c index e12d86a8ffa..1d2a7fa50a0 100644 --- a/sys/dev/ic/dwc_gmac.c +++ b/sys/dev/ic/dwc_gmac.c @@ -1,4 +1,4 @@ -/* $NetBSD: dwc_gmac.c,v 1.73 2021/05/13 05:56:39 msaitoh Exp $ */ +/* $NetBSD: dwc_gmac.c,v 1.74 2021/06/16 00:21:18 riastradh Exp $ */ /*- * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.73 2021/05/13 05:56:39 msaitoh Exp $"); +__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.74 2021/06/16 00:21:18 riastradh Exp $"); /* #define DWC_GMAC_DEBUG 1 */ @@ -188,7 +188,6 @@ dwc_gmac_attach(struct dwc_gmac_softc *sc, int phy_id, uint32_t mii_clk) struct mii_data * const mii = &sc->sc_mii; struct ifnet * const ifp = &sc->sc_ec.ec_if; prop_dictionary_t dict; - int rv; mutex_init(&sc->sc_mdio_lock, MUTEX_DEFAULT, IPL_NET); sc->sc_mii_clk = mii_clk & 7; @@ -332,9 +331,7 @@ dwc_gmac_attach(struct dwc_gmac_softc *sc, int phy_id, uint32_t mii_clk) * Ready, attach interface */ /* Attach the interface. */ - rv = if_initialize(ifp); - if (rv != 0) - goto fail_2; + if_initialize(ifp); sc->sc_ipq = if_percpuq_create(&sc->sc_ec.ec_if); if_deferred_start_init(ifp, NULL); ether_ifattach(ifp, enaddr); @@ -355,12 +352,6 @@ dwc_gmac_attach(struct dwc_gmac_softc *sc, int phy_id, uint32_t mii_clk) return 0; -fail_2: - ifmedia_removeall(&mii->mii_media); - mii_detach(mii, MII_PHY_ANY, MII_OFFSET_ANY); - mutex_destroy(&sc->sc_txq.t_mtx); - mutex_destroy(&sc->sc_rxq.r_mtx); - mutex_obj_free(sc->sc_lock); fail: dwc_gmac_free_rx_ring(sc, &sc->sc_rxq); dwc_gmac_free_tx_ring(sc, &sc->sc_txq); diff --git a/sys/dev/ic/malo.c b/sys/dev/ic/malo.c index 535645dddcf..07aba8cd77d 100644 --- a/sys/dev/ic/malo.c +++ b/sys/dev/ic/malo.c @@ -1,4 +1,4 @@ -/* $NetBSD: malo.c,v 1.18 2020/01/29 15:00:39 thorpej Exp $ */ +/* $NetBSD: malo.c,v 1.19 2021/06/16 00:21:18 riastradh Exp $ */ /* $OpenBSD: malo.c,v 1.92 2010/08/27 17:08:00 jsg Exp $ */ /* @@ -19,7 +19,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: malo.c,v 1.18 2020/01/29 15:00:39 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: malo.c,v 1.19 2021/06/16 00:21:18 riastradh Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -366,7 +366,7 @@ malo_attach(struct malo_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &sc->sc_if; - int i, rv; + int i; /* initialize channel scanning timer */ callout_init(&sc->sc_scan_to, 0); @@ -422,16 +422,7 @@ malo_attach(struct malo_softc *sc) aprint_normal(", address %s\n", ether_sprintf(ic->ic_myaddr)); /* attach interface */ - rv = if_initialize(ifp); - if (rv != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", rv); - malo_free_tx_ring(sc, &sc->sc_txring); - malo_free_rx_ring(sc, &sc->sc_rxring); - malo_free_cmd(sc); - callout_destroy(&sc->sc_scan_to); - - return rv; /* Error */ - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); diff --git a/sys/dev/ic/rt2560.c b/sys/dev/ic/rt2560.c index 7d21b6b820c..b32f6de6f8e 100644 --- a/sys/dev/ic/rt2560.c +++ b/sys/dev/ic/rt2560.c @@ -1,4 +1,4 @@ -/* $NetBSD: rt2560.c,v 1.38 2020/01/29 15:06:12 thorpej Exp $ */ +/* $NetBSD: rt2560.c,v 1.39 2021/06/16 00:21:18 riastradh Exp $ */ /* $OpenBSD: rt2560.c,v 1.15 2006/04/20 20:31:12 miod Exp $ */ /* $FreeBSD: rt2560.c,v 1.3 2006/03/21 21:15:43 damien Exp $*/ @@ -24,7 +24,7 @@ * http://www.ralinktech.com/ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rt2560.c,v 1.38 2020/01/29 15:06:12 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rt2560.c,v 1.39 2021/06/16 00:21:18 riastradh Exp $"); #include <sys/param.h> @@ -441,12 +441,7 @@ rt2560_attach(void *xsc, int id) IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ; } - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - goto fail6; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); @@ -485,7 +480,6 @@ rt2560_attach(void *xsc, int id) return 0; -fail6: rt2560_free_rx_ring(sc, &sc->rxq); fail5: rt2560_free_tx_ring(sc, &sc->bcnq); fail4: rt2560_free_tx_ring(sc, &sc->prioq); fail3: rt2560_free_tx_ring(sc, &sc->atimq); diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c index 8be915d72f5..3bdeed88e45 100644 --- a/sys/dev/ic/rt2661.c +++ b/sys/dev/ic/rt2661.c @@ -1,4 +1,4 @@ -/* $NetBSD: rt2661.c,v 1.43 2020/01/29 15:06:12 thorpej Exp $ */ +/* $NetBSD: rt2661.c,v 1.44 2021/06/16 00:21:18 riastradh Exp $ */ /* $OpenBSD: rt2661.c,v 1.17 2006/05/01 08:41:11 damien Exp $ */ /* $FreeBSD: rt2560.c,v 1.5 2006/06/02 19:59:31 csjp Exp $ */ @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rt2661.c,v 1.43 2020/01/29 15:06:12 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rt2661.c,v 1.44 2021/06/16 00:21:18 riastradh Exp $"); #include <sys/param.h> @@ -330,12 +330,7 @@ rt2661_attach(void *xsc, int id) IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ; } - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - goto fail7; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); @@ -373,7 +368,6 @@ rt2661_attach(void *xsc, int id) return 0; -fail7: rt2661_free_rx_ring(sc, &sc->rxq); fail6: rt2661_free_tx_ring(sc, &sc->mgtq); fail5: rt2661_free_tx_ring(sc, &sc->txq[3]); fail4: rt2661_free_tx_ring(sc, &sc->txq[2]); diff --git a/sys/dev/ic/rt2860.c b/sys/dev/ic/rt2860.c index d4b9dd6271c..0238b02bad0 100644 --- a/sys/dev/ic/rt2860.c +++ b/sys/dev/ic/rt2860.c @@ -1,4 +1,4 @@ -/* $NetBSD: rt2860.c,v 1.35 2020/01/29 15:06:12 thorpej Exp $ */ +/* $NetBSD: rt2860.c,v 1.36 2021/06/16 00:21:18 riastradh Exp $ */ /* $OpenBSD: rt2860.c,v 1.90 2016/04/13 10:49:26 mpi Exp $ */ /* $FreeBSD: head/sys/dev/ral/rt2860.c 306591 2016-10-02 20:35:55Z avos $ */ @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.35 2020/01/29 15:06:12 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.36 2021/06/16 00:21:18 riastradh Exp $"); #include <sys/param.h> #include <sys/sockio.h> @@ -401,25 +401,7 @@ rt2860_attachhook(device_t self) IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); - error = if_initialize(ifp); - if (error != 0) { - int qid; - - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - for (qid = 0; qid < MAXQS; qid++) - rt2860_free_tx_ring(sc, &sc->txq[qid]); - rt2860_free_rx_ring(sc, &sc->rxq); - rt2860_free_tx_pool(sc); - - if (sc->sc_soft_ih != NULL) { - softint_disestablish(sc->sc_soft_ih); - sc->sc_soft_ih = NULL; - } - if (sc->ucode != NULL) - firmware_free(sc->ucode, sc->ucsize); - return; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); diff --git a/sys/dev/ic/rtw.c b/sys/dev/ic/rtw.c index d88f3f070c0..6249e566e6a 100644 --- a/sys/dev/ic/rtw.c +++ b/sys/dev/ic/rtw.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtw.c,v 1.135 2020/01/29 15:06:12 thorpej Exp $ */ +/* $NetBSD: rtw.c,v 1.136 2021/06/16 00:21:18 riastradh Exp $ */ /*- * Copyright (c) 2004, 2005, 2006, 2007 David Young. All rights * reserved. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.135 2020/01/29 15:06:12 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.136 2021/06/16 00:21:18 riastradh Exp $"); #include <sys/param.h> @@ -4224,11 +4224,7 @@ rtw_attach(struct rtw_softc *sc) /* * Call MI attach routines. */ - rc = if_initialize(ifp); - if (rc != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", rc); - goto err; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); diff --git a/sys/dev/ic/wi.c b/sys/dev/ic/wi.c index 787fcc481a9..602ce27ce55 100644 --- a/sys/dev/ic/wi.c +++ b/sys/dev/ic/wi.c @@ -1,4 +1,4 @@ -/* $NetBSD: wi.c,v 1.255 2020/01/30 04:56:11 thorpej Exp $ */ +/* $NetBSD: wi.c,v 1.256 2021/06/16 00:21:18 riastradh Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -99,7 +99,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.255 2020/01/30 04:56:11 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.256 2021/06/16 00:21:18 riastradh Exp $"); #define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */ #define WI_HERMES_STATS_WAR /* Work around stats counter bug. */ @@ -370,7 +370,7 @@ wi_attach(struct wi_softc *sc, const uint8_t *macaddr) static const uint8_t empty_macaddr[IEEE80211_ADDR_LEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - int s, rv; + int s; sc->sc_soft_ih = softint_establish(SOFTINT_NET, wi_softintr, sc); if (sc->sc_soft_ih == NULL) { @@ -546,11 +546,7 @@ wi_attach(struct wi_softc *sc, const uint8_t *macaddr) /* * Call MI attach routines. */ - rv = if_initialize(ifp); - if (rv != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", rv); - goto fail_2; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); @@ -588,9 +584,6 @@ wi_attach(struct wi_softc *sc, const uint8_t *macaddr) ieee80211_announce(ic); return 0; -fail_2: - callout_destroy(&sc->sc_rssadapt_ch); - fail: splx(s); softint_disestablish(sc->sc_soft_ih); sc->sc_soft_ih = NULL; diff --git a/sys/dev/pci/if_aq.c b/sys/dev/pci/if_aq.c index c1239572e63..eaafda9d899 100644 --- a/sys/dev/pci/if_aq.c +++ b/sys/dev/pci/if_aq.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_aq.c,v 1.26 2021/06/13 10:05:39 mlelstv Exp $ */ +/* $NetBSD: if_aq.c,v 1.27 2021/06/16 00:21:18 riastradh Exp $ */ /** * aQuantia Corporation Network Driver @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.26 2021/06/13 10:05:39 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aq.c,v 1.27 2021/06/16 00:21:18 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_if_aq.h" @@ -1458,12 +1458,7 @@ aq_attach(device_t parent, device_t self, void *aux) ifp->if_capabilities |= IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_TCPv6_Rx; ifp->if_capabilities |= IFCAP_CSUM_UDPv4_Rx | IFCAP_CSUM_UDPv6_Rx; - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - goto attach_failure; - } + if_initialize(ifp); ifp->if_percpuq = if_percpuq_create(ifp); if_deferred_start_init(ifp, NULL); ether_ifattach(ifp, sc->sc_enaddr.ether_addr_octet); diff --git a/sys/dev/pci/if_iavf.c b/sys/dev/pci/if_iavf.c index 87dfcc797ae..25cec2079f2 100644 --- a/sys/dev/pci/if_iavf.c +++ b/sys/dev/pci/if_iavf.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_iavf.c,v 1.13 2021/03/05 13:21:07 yamaguchi Exp $ */ +/* $NetBSD: if_iavf.c,v 1.14 2021/06/16 00:21:18 riastradh Exp $ */ /* * Copyright (c) 2013-2015, Intel Corporation @@ -75,7 +75,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_iavf.c,v 1.13 2021/03/05 13:21:07 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iavf.c,v 1.14 2021/06/16 00:21:18 riastradh Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -876,11 +876,7 @@ iavf_attach(device_t parent, device_t self, void *aux) goto teardown_wqs; } - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(self, "if_initialize failed=%d\n", error); - goto teardown_wqs; - } + if_initialize(ifp); strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ); diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c index ac42ef2cf7e..d0269fd2bba 100644 --- a/sys/dev/pci/if_ipw.c +++ b/sys/dev/pci/if_ipw.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ipw.c,v 1.73 2020/01/30 06:03:34 thorpej Exp $ */ +/* $NetBSD: if_ipw.c,v 1.74 2021/06/16 00:21:18 riastradh Exp $ */ /* FreeBSD: src/sys/dev/ipw/if_ipw.c,v 1.15 2005/11/13 17:17:40 damien Exp */ /*- @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.73 2020/01/30 06:03:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.74 2021/06/16 00:21:18 riastradh Exp $"); /*- * Intel(R) PRO/Wireless 2100 MiniPCI driver @@ -298,13 +298,7 @@ ipw_attach(device_t parent, device_t self, void *aux) aprint_normal_dev(sc->sc_dev, "802.11 address %s\n", ether_sprintf(ic->ic_myaddr)); - error = if_initialize(ifp); - if (error != 0) { - ifp->if_softc = NULL; /* For ipw_detach(). */ - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - goto fail; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); diff --git a/sys/dev/pci/if_iwi.c b/sys/dev/pci/if_iwi.c index 1d9ebe55696..b8281f851e8 100644 --- a/sys/dev/pci/if_iwi.c +++ b/sys/dev/pci/if_iwi.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_iwi.c,v 1.115 2021/05/08 00:27:02 thorpej Exp $ */ +/* $NetBSD: if_iwi.c,v 1.116 2021/06/16 00:21:18 riastradh Exp $ */ /* $OpenBSD: if_iwi.c,v 1.111 2010/11/15 19:11:57 damien Exp $ */ /*- @@ -19,7 +19,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.115 2021/05/08 00:27:02 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.116 2021/06/16 00:21:18 riastradh Exp $"); /*- * Intel(R) PRO/Wireless 2200BG/2225BG/2915ABG driver @@ -364,13 +364,7 @@ iwi_attach(device_t parent, device_t self, void *aux) IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, device_xname(self), IFNAMSIZ); - error = if_initialize(ifp); - if (error != 0) { - ifp->if_softc = NULL; /* For iwi_detach() */ - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - goto fail; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index 3f83d277737..3139ced7a0e 100644 --- a/sys/dev/pci/if_iwm.c +++ b/sys/dev/pci/if_iwm.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_iwm.c,v 1.85 2020/05/22 20:27:16 thorpej Exp $ */ +/* $NetBSD: if_iwm.c,v 1.86 2021/06/16 00:21:18 riastradh Exp $ */ /* OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp */ #define IEEE80211_NO_HT /* @@ -106,7 +106,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.85 2020/05/22 20:27:16 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.86 2021/06/16 00:21:18 riastradh Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -8136,12 +8136,7 @@ iwm_attach(device_t parent, device_t self, void *aux) IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, DEVNAME(sc), IFNAMSIZ); - err = if_initialize(ifp); - if (err != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - err); - goto fail6; - } + if_initialize(ifp); #if 0 ieee80211_ifattach(ic); #else @@ -8193,7 +8188,6 @@ iwm_attach(device_t parent, device_t self, void *aux) return; -fail6: iwm_free_rx_ring(sc, &sc->rxq); fail5: while (--txq_i >= 0) iwm_free_tx_ring(sc, &sc->txq[txq_i]); fail4: iwm_dma_contig_free(&sc->sched_dma); diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c index 6256c901f40..cdd3bf3ee77 100644 --- a/sys/dev/pci/if_iwn.c +++ b/sys/dev/pci/if_iwn.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_iwn.c,v 1.95 2021/05/08 00:27:02 thorpej Exp $ */ +/* $NetBSD: if_iwn.c,v 1.96 2021/06/16 00:21:18 riastradh Exp $ */ /* $OpenBSD: if_iwn.c,v 1.135 2014/09/10 07:22:09 dcoppa Exp $ */ /*- @@ -22,7 +22,7 @@ * adapters. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.95 2021/05/08 00:27:02 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.96 2021/06/16 00:21:18 riastradh Exp $"); #define IWN_USE_RBUF /* Use local storage for RX */ #undef IWN_HWCRYPTO /* XXX does not even compile yet */ @@ -659,12 +659,7 @@ iwn_attach(device_t parent __unused, device_t self, void *aux) IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, device_xname(self), IFNAMSIZ); - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - goto fail5; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); @@ -715,7 +710,6 @@ iwn_attach(device_t parent __unused, device_t self, void *aux) return; /* Free allocated memory if something failed during attachment. */ -fail5: iwn_free_rx_ring(sc, &sc->rxq); fail4: while (--i >= 0) iwn_free_tx_ring(sc, &sc->txq[i]); #ifdef IWN_USE_RBUF diff --git a/sys/dev/pci/if_ixl.c b/sys/dev/pci/if_ixl.c index 257a894b5cd..c1d51fd4e32 100644 --- a/sys/dev/pci/if_ixl.c +++ b/sys/dev/pci/if_ixl.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ixl.c,v 1.76 2021/02/09 15:05:49 jakllsch Exp $ */ +/* $NetBSD: if_ixl.c,v 1.77 2021/06/16 00:21:18 riastradh Exp $ */ /* * Copyright (c) 2013-2015, Intel Corporation @@ -74,7 +74,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_ixl.c,v 1.76 2021/02/09 15:05:49 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ixl.c,v 1.77 2021/06/16 00:21:18 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -1316,11 +1316,7 @@ ixl_attach(device_t parent, device_t self, void *aux) ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_NONE, 0, NULL); ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO); - rv = if_initialize(ifp); - if (rv != 0) { - aprint_error_dev(self, "if_initialize failed=%d\n", rv); - goto teardown_wqs; - } + if_initialize(ifp); sc->sc_ipq = if_percpuq_create(ifp); if_deferred_start_init(ifp, NULL); diff --git a/sys/dev/pci/if_rtwn.c b/sys/dev/pci/if_rtwn.c index 3f6a26a86c8..14c8412dee0 100644 --- a/sys/dev/pci/if_rtwn.c +++ b/sys/dev/pci/if_rtwn.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_rtwn.c,v 1.19 2020/01/30 06:03:34 thorpej Exp $ */ +/* $NetBSD: if_rtwn.c,v 1.20 2021/06/16 00:21:18 riastradh Exp $ */ /* $OpenBSD: if_rtwn.c,v 1.5 2015/06/14 08:02:47 stsp Exp $ */ #define IEEE80211_NO_HT /*- @@ -23,7 +23,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_rtwn.c,v 1.19 2020/01/30 06:03:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_rtwn.c,v 1.20 2021/06/16 00:21:18 riastradh Exp $"); #include <sys/param.h> #include <sys/sockio.h> @@ -359,13 +359,7 @@ rtwn_attach(device_t parent, device_t self, void *aux) IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); - error = if_initialize(ifp); - if (error != 0) { - ifp->if_softc = NULL; /* For rtwn_detach() */ - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - goto fail; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); @@ -397,11 +391,6 @@ rtwn_attach(device_t parent, device_t self, void *aux) if (!pmf_device_register(self, NULL, NULL)) aprint_error_dev(self, "couldn't establish power handler\n"); - - return; - -fail: - rtwn_detach(self, 0); } static int diff --git a/sys/dev/pci/if_wm.c b/sys/dev/pci/if_wm.c index 0e6a121927b..8b30ddc8b3b 100644 --- a/sys/dev/pci/if_wm.c +++ b/sys/dev/pci/if_wm.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.704 2021/05/12 10:16:12 knakahara Exp $ */ +/* $NetBSD: if_wm.c,v 1.705 2021/06/16 00:21:18 riastradh Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -82,7 +82,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.704 2021/05/12 10:16:12 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.705 2021/06/16 00:21:18 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -3091,12 +3091,7 @@ alloc_retry: sc->sc_rx_intr_process_limit = WM_RX_INTR_PROCESS_LIMIT_DEFAULT; /* Attach the interface. */ - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - return; /* Error */ - } + if_initialize(ifp); sc->sc_ipq = if_percpuq_create(&sc->sc_ethercom.ec_if); ether_ifattach(ifp, enaddr); ether_set_ifflags_cb(&sc->sc_ethercom, wm_ifflags_cb); diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c index d3217400a47..29c0d3aed98 100644 --- a/sys/dev/pci/if_wpi.c +++ b/sys/dev/pci/if_wpi.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wpi.c,v 1.90 2021/02/05 16:06:24 christos Exp $ */ +/* $NetBSD: if_wpi.c,v 1.91 2021/06/16 00:21:18 riastradh Exp $ */ /*- * Copyright (c) 2006, 2007 @@ -18,7 +18,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.90 2021/02/05 16:06:24 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.91 2021/06/16 00:21:18 riastradh Exp $"); /* * Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters. @@ -370,12 +370,7 @@ wpi_attach(device_t parent __unused, device_t self, void *aux) IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, device_xname(self), IFNAMSIZ); - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", - error); - goto fail5; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); @@ -422,7 +417,6 @@ wpi_attach(device_t parent __unused, device_t self, void *aux) return; /* free allocated memory if something failed during attachment */ -fail5: wpi_free_rx_ring(sc, &sc->rxq); fail4: wpi_free_tx_ring(sc, &sc->cmdq); fail3: while (--ac >= 0) wpi_free_tx_ring(sc, &sc->txq[ac]); diff --git a/sys/dev/pci/ixgbe/ixgbe.c b/sys/dev/pci/ixgbe/ixgbe.c index f198b853392..bb823f05eeb 100644 --- a/sys/dev/pci/ixgbe/ixgbe.c +++ b/sys/dev/pci/ixgbe/ixgbe.c @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.283 2021/05/18 05:29:16 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.284 2021/06/16 00:21:18 riastradh Exp $ */ /****************************************************************************** @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.283 2021/05/18 05:29:16 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.284 2021/06/16 00:21:18 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1335,7 +1335,6 @@ ixgbe_setup_interface(device_t dev, struct adapter *adapter) { struct ethercom *ec = &adapter->osdep.ec; struct ifnet *ifp; - int rv; INIT_DEBUGOUT("ixgbe_setup_interface: begin"); @@ -1370,11 +1369,7 @@ ixgbe_setup_interface(device_t dev, struct adapter *adapter) IFQ_SET_MAXLEN(&ifp->if_snd, adapter->num_tx_desc - 2); IFQ_SET_READY(&ifp->if_snd); - rv = if_initialize(ifp); - if (rv != 0) { - aprint_error_dev(dev, "if_initialize failed(%d)\n", rv); - return rv; - } + if_initialize(ifp); adapter->ipq = if_percpuq_create(&adapter->osdep.ec.ec_if); ether_ifattach(ifp, adapter->hw.mac.addr); aprint_normal_dev(dev, "Ethernet address %s\n", diff --git a/sys/dev/pci/ixgbe/ixv.c b/sys/dev/pci/ixgbe/ixv.c index 6b4e068326f..4a6b42df1b7 100644 --- a/sys/dev/pci/ixgbe/ixv.c +++ b/sys/dev/pci/ixgbe/ixv.c @@ -1,4 +1,4 @@ -/* $NetBSD: ixv.c,v 1.161 2021/05/19 08:19:20 msaitoh Exp $ */ +/* $NetBSD: ixv.c,v 1.162 2021/06/16 00:21:18 riastradh Exp $ */ /****************************************************************************** @@ -35,7 +35,7 @@ /*$FreeBSD: head/sys/dev/ixgbe/if_ixv.c 331224 2018-03-19 20:55:05Z erj $*/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.161 2021/05/19 08:19:20 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.162 2021/06/16 00:21:18 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1620,7 +1620,6 @@ ixv_setup_interface(device_t dev, struct adapter *adapter) { struct ethercom *ec = &adapter->osdep.ec; struct ifnet *ifp; - int rv; INIT_DEBUGOUT("ixv_setup_interface: begin"); @@ -1649,11 +1648,7 @@ ixv_setup_interface(device_t dev, struct adapter *adapter) IFQ_SET_MAXLEN(&ifp->if_snd, adapter->num_tx_desc - 2); IFQ_SET_READY(&ifp->if_snd); - rv = if_initialize(ifp); - if (rv != 0) { - aprint_error_dev(dev, "if_initialize failed(%d)\n", rv); - return rv; - } + if_initialize(ifp); adapter->ipq = if_percpuq_create(&adapter->osdep.ec.ec_if); ether_ifattach(ifp, adapter->hw.mac.addr); aprint_normal_dev(dev, "Ethernet address %s\n", diff --git a/sys/dev/pcmcia/if_malo_pcmcia.c b/sys/dev/pcmcia/if_malo_pcmcia.c index d79fab78297..872cf4b05b5 100644 --- a/sys/dev/pcmcia/if_malo_pcmcia.c +++ b/sys/dev/pcmcia/if_malo_pcmcia.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_malo_pcmcia.c,v 1.25 2020/01/29 13:54:41 thorpej Exp $ */ +/* $NetBSD: if_malo_pcmcia.c,v 1.26 2021/06/16 00:21:19 riastradh Exp $ */ /* $OpenBSD: if_malo.c,v 1.65 2009/03/29 21:53:53 sthen Exp $ */ /* @@ -18,7 +18,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_malo_pcmcia.c,v 1.25 2020/01/29 13:54:41 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_malo_pcmcia.c,v 1.26 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _MODULE #include <sys/module.h> @@ -307,7 +307,7 @@ cmalo_attach(void *arg) struct malo_softc *sc = arg; struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &sc->sc_if; - int i, rv; + int i; /* disable interrupts */ cmalo_intr_mask(sc, 0); @@ -318,7 +318,7 @@ cmalo_attach(void *arg) cmalo_fw_load_main(sc) != 0) { /* free firmware */ cmalo_fw_free(sc); - goto fail_1; + goto fail; } sc->sc_flags |= MALO_FW_LOADED; @@ -368,11 +368,7 @@ cmalo_attach(void *arg) } /* attach interface */ - rv = if_initialize(ifp); - if (rv != 0) { - aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n", rv); - goto fail_2; - } + if_initialize(ifp); ieee80211_ifattach(ic); /* Use common softint-based if_input */ ifp->if_percpuq = if_percpuq_create(ifp); @@ -393,12 +389,7 @@ cmalo_attach(void *arg) return; -fail_2: - cv_destroy(&sc->sc_cv); - mutex_destroy(&sc->sc_mtx); - free(sc->sc_cmd, M_DEVBUF); - free(sc->sc_data, M_DEVBUF); -fail_1: +fail: cmalo_fw_free(sc); } diff --git a/sys/dev/scsipi/if_se.c b/sys/dev/scsipi/if_se.c index ac6940a7cfd..beb21a83fad 100644 --- a/sys/dev/scsipi/if_se.c +++ b/sys/dev/scsipi/if_se.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_se.c,v 1.112 2020/09/29 02:58:52 msaitoh Exp $ */ +/* $NetBSD: if_se.c,v 1.113 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright (c) 1997 Ian W. Dall <ian.dall@dsto.defence.gov.au> @@ -59,7 +59,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.112 2020/09/29 02:58:52 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.113 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -368,11 +368,7 @@ seattach(device_t parent, device_t self, void *aux) sc->sc_attach_state = 1; /* Attach the interface. */ - rv = if_initialize(ifp); - if (rv != 0) { - sedetach(sc->sc_dev, 0); - return; /* Error */ - } + if_initialize(ifp); snprintf(wqname, sizeof(wqname), "%sRx", device_xname(sc->sc_dev)); rv = workqueue_create(&sc->sc_recv_wq, wqname, se_recv_worker, sc, diff --git a/sys/dev/usb/if_umb.c b/sys/dev/usb/if_umb.c index 30b0f585d05..1aead36ba7e 100644 --- a/sys/dev/usb/if_umb.c +++ b/sys/dev/usb/if_umb.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_umb.c,v 1.19 2020/03/24 07:12:16 maxv Exp $ */ +/* $NetBSD: if_umb.c,v 1.20 2021/06/16 00:21:19 riastradh Exp $ */ /* $OpenBSD: if_umb.c,v 1.20 2018/09/10 17:00:45 gerhard Exp $ */ /* @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.19 2020/03/24 07:12:16 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.20 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -311,7 +311,6 @@ umb_attach(device_t parent, device_t self, void *aux) int altnum; int s; struct ifnet *ifp; - int rv; sc->sc_dev = self; sc->sc_udev = uiaa->uiaa_device; @@ -532,12 +531,7 @@ umb_attach(device_t parent, device_t self, void *aux) IFQ_SET_READY(&ifp->if_snd); /* attach the interface */ - rv = if_initialize(ifp); - if (rv != 0) { - aprint_error_dev(self, "if_initialize failed(%d)\n", rv); - splx(s); - return; - } + if_initialize(ifp); if_register(ifp); if_alloc_sadl(ifp); diff --git a/sys/dev/usb/usbnet.c b/sys/dev/usb/usbnet.c index febe25118db..3a825d3deb1 100644 --- a/sys/dev/usb/usbnet.c +++ b/sys/dev/usb/usbnet.c @@ -1,4 +1,4 @@ -/* $NetBSD: usbnet.c,v 1.41 2021/04/25 05:15:20 rin Exp $ */ +/* $NetBSD: usbnet.c,v 1.42 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright (c) 2019 Matthew R. Green @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.41 2021/04/25 05:15:20 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.42 2021/06/16 00:21:19 riastradh Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -1452,11 +1452,7 @@ usbnet_attach_ifp(struct usbnet *un, unp->unp_link = true; /* Attach the interface. */ - int rv = if_initialize(ifp); - if (rv != 0) { - aprint_error_dev(un->un_dev, "if_initialize failed: %d\n", rv); - return; - } + if_initialize(ifp); if (ifp->_if_input == NULL) ifp->if_percpuq = if_percpuq_create(ifp); if_register(ifp); diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index 6bad98eff19..80f4b7e5563 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_arcsubr.c,v 1.82 2020/08/28 06:23:42 ozaki-r Exp $ */ +/* $NetBSD: if_arcsubr.c,v 1.83 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright (c) 1994, 1995 Ignatios Souvatzis @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.82 2020/08/28 06:23:42 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.83 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -605,7 +605,6 @@ int arc_ifattach(struct ifnet *ifp, uint8_t lla) { struct arccom *ac; - int rv; ifp->if_type = IFT_ARCNET; ifp->if_addrlen = 1; @@ -627,9 +626,7 @@ arc_ifattach(struct ifnet *ifp, uint8_t lla) log(LOG_ERR,"%s: link address 0 reserved for broadcasts. Please change it and ifconfig %s down up\n", ifp->if_xname, ifp->if_xname); } - rv = if_attach(ifp); - if (rv != 0) - return rv; + if_attach(ifp); if_set_sadl(ifp, &lla, sizeof(lla), true); diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 54c9a34e23f..8d639221dae 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_bridge.c,v 1.179 2021/02/19 14:51:59 christos Exp $ */ +/* $NetBSD: if_bridge.c,v 1.180 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -80,7 +80,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.179 2021/02/19 14:51:59 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.180 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -451,19 +451,7 @@ bridge_clone_create(struct if_clone *ifc, int unit) ifp->if_addrlen = 0; ifp->if_dlt = DLT_EN10MB; ifp->if_hdrlen = ETHER_HDR_LEN; - - error = if_initialize(ifp); - if (error != 0) { - pserialize_destroy(sc->sc_iflist_psref.bip_psz); - mutex_destroy(&sc->sc_iflist_psref.bip_lock); - callout_destroy(&sc->sc_brcallout); - callout_destroy(&sc->sc_bstpcallout); - workqueue_destroy(sc->sc_rtage_wq); - bridge_rtable_fini(sc); - kmem_free(sc, sizeof(*sc)); - - return error; - } + if_initialize(ifp); /* * Set the link state to down. diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c index 3159fcf5904..2590bb2f76a 100644 --- a/sys/net/if_faith.c +++ b/sys/net/if_faith.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_faith.c,v 1.61 2020/01/29 04:18:34 thorpej Exp $ */ +/* $NetBSD: if_faith.c,v 1.62 2021/06/16 00:21:19 riastradh Exp $ */ /* $KAME: if_faith.c,v 1.21 2001/02/20 07:59:26 itojun Exp $ */ /* @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_faith.c,v 1.61 2020/01/29 04:18:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_faith.c,v 1.62 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -137,7 +137,6 @@ static int faith_clone_create(struct if_clone *ifc, int unit) { struct ifnet *ifp; - int rv; ifp = if_alloc(IFT_FAITH); @@ -152,11 +151,7 @@ faith_clone_create(struct if_clone *ifc, int unit) ifp->if_hdrlen = 0; ifp->if_addrlen = 0; ifp->if_dlt = DLT_NULL; - rv = if_attach(ifp); - if (rv != 0) { - if_free(ifp); - return rv; - } + if_attach(ifp); if_alloc_sadl(ifp); bpf_attach(ifp, DLT_NULL, sizeof(u_int)); atomic_inc_uint(&faith_count); diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index f346da1fea1..e71b37034e9 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_gif.c,v 1.154 2020/10/14 15:22:17 roy Exp $ */ +/* $NetBSD: if_gif.c,v 1.155 2021/06/16 00:21:19 riastradh Exp $ */ /* $KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $ */ /* @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.154 2020/10/14 15:22:17 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.155 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -379,7 +379,6 @@ gif_clone_create(struct if_clone *ifc, int unit) static int gifattach0(struct gif_softc *sc) { - int rv; sc->gif_if.if_addrlen = 0; sc->gif_if.if_mtu = GIF_MTU; @@ -395,9 +394,7 @@ gifattach0(struct gif_softc *sc) sc->gif_if.if_dlt = DLT_NULL; sc->gif_if.if_softc = sc; IFQ_SET_READY(&sc->gif_if.if_snd); - rv = if_initialize(&sc->gif_if); - if (rv != 0) - return rv; + if_initialize(&sc->gif_if); sc->gif_if.if_link_state = LINK_STATE_DOWN; if_alloc_sadl(&sc->gif_if); diff --git a/sys/net/if_l2tp.c b/sys/net/if_l2tp.c index aa3c10be429..af2ce9baec4 100644 --- a/sys/net/if_l2tp.c +++ b/sys/net/if_l2tp.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_l2tp.c,v 1.46 2020/10/25 08:18:39 roy Exp $ */ +/* $NetBSD: if_l2tp.c,v 1.47 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright (c) 2017 Internet Initiative Japan Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.46 2020/10/25 08:18:39 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.47 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -281,7 +281,6 @@ l2tp_clone_create(struct if_clone *ifc, int unit) int l2tpattach0(struct l2tp_softc *sc) { - int rv; sc->l2tp_ec.ec_if.if_addrlen = 0; sc->l2tp_ec.ec_if.if_mtu = L2TP_MTU; @@ -321,9 +320,7 @@ l2tpattach0(struct l2tp_softc *sc) * if_percpuq_enqueue(). However, that causes recursive softnet_lock * when NET_MPSAFE is not set. */ - rv = if_attach(&sc->l2tp_ec.ec_if); - if (rv != 0) - return rv; + if_attach(&sc->l2tp_ec.ec_if); if_link_state_change(&sc->l2tp_ec.ec_if, LINK_STATE_DOWN); if_alloc_sadl(&sc->l2tp_ec.ec_if); bpf_attach(&sc->l2tp_ec.ec_if, DLT_EN10MB, sizeof(struct ether_header)); diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 6e4c8dcf484..ff2a401d53a 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_loop.c,v 1.112 2020/10/14 16:10:32 roy Exp $ */ +/* $NetBSD: if_loop.c,v 1.113 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.112 2020/10/14 16:10:32 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.113 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -175,7 +175,6 @@ static int loop_clone_create(struct if_clone *ifc, int unit) { struct ifnet *ifp; - int rv; ifp = if_alloc(IFT_LOOP); @@ -198,11 +197,7 @@ loop_clone_create(struct if_clone *ifc, int unit) IFQ_SET_READY(&ifp->if_snd); if (unit == 0) lo0ifp = ifp; - rv = if_initialize(ifp); - if (rv != 0) { - if_free(ifp); - return rv; - } + if_initialize(ifp); ifp->if_link_state = LINK_STATE_UP; if_alloc_sadl(ifp); bpf_attach(ifp, DLT_NULL, sizeof(u_int)); diff --git a/sys/net/if_mpls.c b/sys/net/if_mpls.c index 849402cbea6..a6fbc6957ae 100644 --- a/sys/net/if_mpls.c +++ b/sys/net/if_mpls.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_mpls.c,v 1.36 2020/01/29 04:18:34 thorpej Exp $ */ +/* $NetBSD: if_mpls.c,v 1.37 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.36 2020/01/29 04:18:34 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.37 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -139,7 +139,6 @@ static int mpls_clone_create(struct if_clone *ifc, int unit) { struct mpls_softc *sc; - int rv; atomic_inc_uint(&mpls_count); sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); @@ -156,12 +155,7 @@ mpls_clone_create(struct if_clone *ifc, int unit) sc->sc_if.if_output = mpls_output; sc->sc_if.if_ioctl = mpls_ioctl; - rv = if_attach(&sc->sc_if); - if (rv != 0) { - free(sc, M_DEVBUF); - atomic_dec_uint(&mpls_count); - return rv; - } + if_attach(&sc->sc_if); if_alloc_sadl(&sc->sc_if); bpf_attach(&sc->sc_if, DLT_NULL, sizeof(uint32_t)); return 0; diff --git a/sys/net/if_pppoe.c b/sys/net/if_pppoe.c index 4f5769a6108..98c8e64c046 100644 --- a/sys/net/if_pppoe.c +++ b/sys/net/if_pppoe.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppoe.c,v 1.176 2021/05/19 03:44:46 yamaguchi Exp $ */ +/* $NetBSD: if_pppoe.c,v 1.177 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.176 2021/05/19 03:44:46 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.177 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "pppoe.h" @@ -389,9 +389,7 @@ pppoe_clone_create(struct if_clone *ifc, int unit) callout_init(&sc->sc_timeout, CALLOUT_MPSAFE); callout_setfunc(&sc->sc_timeout, pppoe_timeout_co, sc); - rv = if_initialize(ifp); - if (rv != 0) - goto destroy_timeout; + if_initialize(ifp); ifp->if_percpuq = if_percpuq_create(ifp); @@ -408,9 +406,6 @@ pppoe_clone_create(struct if_clone *ifc, int unit) return 0; -destroy_timeout: - callout_destroy(&sc->sc_timeout); - workqueue_destroy(sc->sc_timeout_wq); destroy_sclock: rw_destroy(&sc->sc_lock); kmem_free(sc, sizeof(*sc)); diff --git a/sys/net/if_srt.c b/sys/net/if_srt.c index a1719532b3a..edff0d9987c 100644 --- a/sys/net/if_srt.c +++ b/sys/net/if_srt.c @@ -1,8 +1,8 @@ -/* $NetBSD: if_srt.c,v 1.31 2020/01/29 04:28:27 thorpej Exp $ */ +/* $NetBSD: if_srt.c,v 1.32 2021/06/16 00:21:19 riastradh Exp $ */ /* This file is in the public domain. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_srt.c,v 1.31 2020/01/29 04:28:27 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_srt.c,v 1.32 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -272,7 +272,6 @@ static int srt_clone_create(struct if_clone *cl, int unit) { struct srt_softc *sc; - int rv; if (unit < 0 || unit > SRT_MAXUNIT) return ENXIO; @@ -292,13 +291,7 @@ srt_clone_create(struct if_clone *cl, int unit) sc->intf.if_ioctl = &srt_if_ioctl; sc->intf.if_output = &srt_if_output; sc->intf.if_dlt = DLT_RAW; - rv = if_attach(&sc->intf); - if (rv != 0) { - aprint_error("%s: if_initialize failed(%d)\n", - sc->intf.if_xname, rv); - free(sc, M_DEVBUF); - return rv; - } + if_attach(&sc->intf); if_alloc_sadl(&sc->intf); #ifdef BPFILTER_NOW_AVAILABLE bpf_attach(&sc->intf, 0, 0); diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index 5e9d824d741..9f70db8e9da 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_stf.c,v 1.107 2020/01/29 04:28:27 thorpej Exp $ */ +/* $NetBSD: if_stf.c,v 1.108 2021/06/16 00:21:19 riastradh Exp $ */ /* $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */ /* @@ -75,7 +75,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.107 2020/01/29 04:28:27 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.108 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -236,16 +236,7 @@ stf_clone_create(struct if_clone *ifc, int unit) sc->sc_if.if_output = stf_output; sc->sc_if.if_type = IFT_STF; sc->sc_if.if_dlt = DLT_NULL; - error = if_attach(&sc->sc_if); - if (error != 0) { - aprint_error("%s: if_initialize failed(%d)\n", - if_name(&sc->sc_if), error); - encap_lock_enter(); - encap_detach(sc->encap_cookie); - encap_lock_exit(); - free(sc, M_DEVBUF); - return error; - } + if_attach(&sc->sc_if); if_alloc_sadl(&sc->sc_if); bpf_attach(&sc->sc_if, DLT_NULL, sizeof(u_int)); LIST_INSERT_HEAD(&stf_softc_list, sc, sc_list); diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index ce947c469e6..a97010c9ecf 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_tap.c,v 1.121 2020/12/18 01:31:49 thorpej Exp $ */ +/* $NetBSD: if_tap.c,v 1.122 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation. @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.121 2020/12/18 01:31:49 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.122 2021/06/16 00:21:19 riastradh Exp $"); #if defined(_KERNEL_OPT) @@ -346,15 +346,7 @@ tap_attach(device_t parent, device_t self, void *aux) sc->sc_ec.ec_capabilities = ETHERCAP_VLAN_MTU | ETHERCAP_JUMBO_MTU; /* Those steps are mandatory for an Ethernet driver. */ - error = if_initialize(ifp); - if (error != 0) { - aprint_error_dev(self, "if_initialize failed(%d)\n", error); - pmf_device_deregister(self); - mutex_destroy(&sc->sc_lock); - seldestroy(&sc->sc_rsel); - - return; /* Error */ - } + if_initialize(ifp); ifp->if_percpuq = if_percpuq_create(ifp); ether_ifattach(ifp, enaddr); /* Opening the device will bring the link state up. */ diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 7901267f805..33eabe4a6f4 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_vlan.c,v 1.153 2020/09/26 18:38:09 roy Exp $ */ +/* $NetBSD: if_vlan.c,v 1.154 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -78,7 +78,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.153 2020/09/26 18:38:09 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.154 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -333,7 +333,6 @@ vlan_clone_create(struct if_clone *ifc, int unit) struct ifvlan *ifv; struct ifnet *ifp; struct ifvlan_linkmib *mib; - int rv; ifv = malloc(sizeof(struct ifvlan), M_DEVBUF, M_WAITOK | M_ZERO); mib = kmem_zalloc(sizeof(struct ifvlan_linkmib), KM_SLEEP); @@ -362,14 +361,7 @@ vlan_clone_create(struct if_clone *ifc, int unit) ifp->if_transmit = vlan_transmit; ifp->if_ioctl = vlan_ioctl; IFQ_SET_READY(&ifp->if_snd); - - rv = if_initialize(ifp); - if (rv != 0) { - aprint_error("%s: if_initialize failed(%d)\n", ifp->if_xname, - rv); - goto fail; - } - + if_initialize(ifp); /* * Set the link state to down. * When the parent interface attaches we will use that link state. @@ -380,18 +372,6 @@ vlan_clone_create(struct if_clone *ifc, int unit) vlan_reset_linkname(ifp); if_register(ifp); return 0; - -fail: - mutex_enter(&ifv_list.lock); - LIST_REMOVE(ifv, ifv_list); - mutex_exit(&ifv_list.lock); - - mutex_destroy(&ifv->ifv_lock); - psref_target_destroy(&ifv->ifv_mib->ifvm_psref, ifvm_psref_class); - kmem_free(ifv->ifv_mib, sizeof(struct ifvlan_linkmib)); - free(ifv, M_DEVBUF); - - return rv; } static int diff --git a/sys/net/if_wg.c b/sys/net/if_wg.c index f4b256c6fa1..58745d78ff5 100644 --- a/sys/net/if_wg.c +++ b/sys/net/if_wg.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.63 2021/04/29 17:55:51 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.64 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki <ozaki.ryota@gmail.com> @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.63 2021/04/29 17:55:51 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.64 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -3558,7 +3558,6 @@ wg_destroy_peer_name(struct wg_softc *wg, const char *name) static int wg_if_attach(struct wg_softc *wg) { - int error; wg->wg_if.if_addrlen = 0; wg->wg_if.if_mtu = WG_MTU; @@ -3577,10 +3576,7 @@ wg_if_attach(struct wg_softc *wg) #ifdef ALTQ IFQ_SET_READY(&wg->wg_if.if_snd); #endif - - error = if_initialize(&wg->wg_if); - if (error != 0) - return error; + if_initialize(&wg->wg_if); wg->wg_if.if_link_state = LINK_STATE_DOWN; if_alloc_sadl(&wg->wg_if); diff --git a/sys/net/lagg/if_lagg.c b/sys/net/lagg/if_lagg.c index 586b0ed1626..2e3073e96f3 100644 --- a/sys/net/lagg/if_lagg.c +++ b/sys/net/lagg/if_lagg.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_lagg.c,v 1.4 2021/05/24 13:42:58 thorpej Exp $ */ +/* $NetBSD: if_lagg.c,v 1.5 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -20,7 +20,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.4 2021/05/24 13:42:58 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.5 2021/06/16 00:21:19 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -381,9 +381,7 @@ lagg_clone_create(struct if_clone *ifc, int unit) ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO); - error = if_initialize(ifp); - if (error != 0) - goto cleanup_ifmedia; + if_initialize(ifp); switch (lagg_iftype) { case LAGG_IF_TYPE_ETHERNET: @@ -406,9 +404,6 @@ lagg_clone_create(struct if_clone *ifc, int unit) return 0; -cleanup_ifmedia: - ifmedia_fini(&sc->sc_media); - lagg_teardown_sysctls(sc); destroy_psz: pserialize_destroy(sc->sc_psz); mutex_destroy(&sc->sc_lock); diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index e2194e535cf..b2d92871774 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_carp.c,v 1.114 2020/10/14 13:43:56 roy Exp $ */ +/* $NetBSD: ip_carp.c,v 1.115 2021/06/16 00:21:19 riastradh Exp $ */ /* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */ /* @@ -33,7 +33,7 @@ #endif #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.114 2020/10/14 13:43:56 roy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.115 2021/06/16 00:21:19 riastradh Exp $"); /* * TODO: @@ -843,7 +843,6 @@ carp_clone_create(struct if_clone *ifc, int unit) extern int ifqmaxlen; struct carp_softc *sc; struct ifnet *ifp; - int rv; sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO); if (!sc) @@ -877,15 +876,7 @@ carp_clone_create(struct if_clone *ifc, int unit) ifp->if_start = carp_start; IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); IFQ_SET_READY(&ifp->if_snd); - rv = if_initialize(ifp); - if (rv != 0) { - callout_destroy(&sc->sc_ad_tmo); - callout_destroy(&sc->sc_md_tmo); - callout_destroy(&sc->sc_md6_tmo); - free(ifp->if_softc, M_DEVBUF); - - return rv; - } + if_initialize(ifp); ether_ifattach(ifp, NULL); /* Overwrite ethernet defaults */ ifp->if_type = IFT_CARP; diff --git a/sys/rump/net/lib/libshmif/if_shmem.c b/sys/rump/net/lib/libshmif/if_shmem.c index acd7085662f..ab32753f9d9 100644 --- a/sys/rump/net/lib/libshmif/if_shmem.c +++ b/sys/rump/net/lib/libshmif/if_shmem.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_shmem.c,v 1.81 2020/02/25 03:26:18 ozaki-r Exp $ */ +/* $NetBSD: if_shmem.c,v 1.82 2021/06/16 00:21:19 riastradh Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.81 2020/02/25 03:26:18 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.82 2021/06/16 00:21:19 riastradh Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -164,7 +164,7 @@ allocif(int unit, struct shmif_sc **scp) struct shmif_sc *sc; struct ifnet *ifp; uint64_t randnum; - int error; + int error = 0; randnum = cprng_strong64(); memcpy(&enaddr[2], &randnum, 4); @@ -195,16 +195,7 @@ allocif(int unit, struct shmif_sc **scp) mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_NONE); cv_init(&sc->sc_cv, "shmifcv"); - error = if_initialize(ifp); - if (error != 0) { - aprint_error("shmif%d: if_initialize failed(%d)\n", unit, - error); - cv_destroy(&sc->sc_cv); - mutex_destroy(&sc->sc_mtx); - kmem_free(sc, sizeof(*sc)); - - return error; - } + if_initialize(ifp); #if 1 char buf[256]; @@ -224,7 +215,6 @@ allocif(int unit, struct shmif_sc **scp) if (scp) *scp = sc; - error = 0; if (rump_threads) { error = kthread_create(PRI_NONE, KTHREAD_MPSAFE | KTHREAD_MUSTJOIN, NULL, @@ -237,7 +227,7 @@ allocif(int unit, struct shmif_sc **scp) shmif_unclone(ifp); } - return error; + return 0; } static int diff --git a/sys/rump/net/lib/libvirtif/if_virt.c b/sys/rump/net/lib/libvirtif/if_virt.c index 5406ea956bd..46800769879 100644 --- a/sys/rump/net/lib/libvirtif/if_virt.c +++ b/sys/rump/net/lib/libvirtif/if_virt.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_virt.c,v 1.58 2020/02/01 22:45:01 thorpej Exp $ */ +/* $NetBSD: if_virt.c,v 1.59 2021/06/16 00:21:20 riastradh Exp $ */ /* * Copyright (c) 2008, 2013 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.58 2020/02/01 22:45:01 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.59 2021/06/16 00:21:20 riastradh Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -121,13 +121,7 @@ virtif_clone(struct if_clone *ifc, int num) ifp->if_mtu = ETHERMTU; ifp->if_dlt = DLT_EN10MB; - error = if_initialize(ifp); - if (error != 0) { - aprint_error("%s: if_initialize failed(%d)\n", ifp->if_xname, - error); - goto fail_1; - } - + if_initialize(ifp); if_register(ifp); #ifndef RUMP_VIF_LINKSTR @@ -140,17 +134,16 @@ virtif_clone(struct if_clone *ifc, int num) sc->sc_linkstr = kmem_alloc(LINKSTRNUMLEN, KM_SLEEP); if (sc->sc_linkstr == NULL) { error = ENOMEM; - goto fail_2; + goto fail; } snprintf(sc->sc_linkstr, LINKSTRNUMLEN, "%d", sc->sc_num); error = virtif_create(ifp); if (error) { -fail_2: +fail: if_detach(ifp); if (sc->sc_linkstr != NULL) kmem_free(sc->sc_linkstr, LINKSTRNUMLEN); #undef LINKSTRNUMLEN -fail_1: kmem_free(sc, sizeof(*sc)); ifp->if_softc = NULL; } |
