Module Name: src Committed By: riastradh Date: Wed Jun 16 00:21:20 UTC 2021
Modified Files: src/share/man/man4: usbnet.4 src/sys/arch/arm/broadcom: bcm53xx_eth.c src/sys/arch/powerpc/booke/dev: pq3etsec.c src/sys/arch/usermode/dev: if_veth.c src/sys/dev/hyperv: if_hvn.c src/sys/dev/ic: an.c athn.c atw.c bwfm.c bwi.c dwc_gmac.c malo.c rt2560.c rt2661.c rt2860.c rtw.c wi.c src/sys/dev/pci: if_aq.c if_iavf.c if_ipw.c if_iwi.c if_iwm.c if_iwn.c if_ixl.c if_rtwn.c if_wm.c if_wpi.c src/sys/dev/pci/ixgbe: ixgbe.c ixv.c src/sys/dev/pcmcia: if_malo_pcmcia.c src/sys/dev/scsipi: if_se.c src/sys/dev/usb: if_umb.c usbnet.c src/sys/net: if_arcsubr.c if_bridge.c if_faith.c if_gif.c if_l2tp.c if_loop.c if_mpls.c if_pppoe.c if_srt.c if_stf.c if_tap.c if_vlan.c if_wg.c src/sys/net/lagg: if_lagg.c src/sys/netinet: ip_carp.c src/sys/rump/net/lib/libshmif: if_shmem.c src/sys/rump/net/lib/libvirtif: if_virt.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/usbnet.4 cvs rdiff -u -r1.40 -r1.41 src/sys/arch/arm/broadcom/bcm53xx_eth.c cvs rdiff -u -r1.54 -r1.55 src/sys/arch/powerpc/booke/dev/pq3etsec.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/usermode/dev/if_veth.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/hyperv/if_hvn.c cvs rdiff -u -r1.74 -r1.75 src/sys/dev/ic/an.c cvs rdiff -u -r1.24 -r1.25 src/sys/dev/ic/athn.c cvs rdiff -u -r1.170 -r1.171 src/sys/dev/ic/atw.c cvs rdiff -u -r1.30 -r1.31 src/sys/dev/ic/bwfm.c cvs rdiff -u -r1.37 -r1.38 src/sys/dev/ic/bwi.c cvs rdiff -u -r1.73 -r1.74 src/sys/dev/ic/dwc_gmac.c cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ic/malo.c cvs rdiff -u -r1.38 -r1.39 src/sys/dev/ic/rt2560.c cvs rdiff -u -r1.43 -r1.44 src/sys/dev/ic/rt2661.c cvs rdiff -u -r1.35 -r1.36 src/sys/dev/ic/rt2860.c cvs rdiff -u -r1.135 -r1.136 src/sys/dev/ic/rtw.c cvs rdiff -u -r1.255 -r1.256 src/sys/dev/ic/wi.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/if_aq.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/if_iavf.c cvs rdiff -u -r1.73 -r1.74 src/sys/dev/pci/if_ipw.c cvs rdiff -u -r1.115 -r1.116 src/sys/dev/pci/if_iwi.c cvs rdiff -u -r1.85 -r1.86 src/sys/dev/pci/if_iwm.c cvs rdiff -u -r1.95 -r1.96 src/sys/dev/pci/if_iwn.c cvs rdiff -u -r1.76 -r1.77 src/sys/dev/pci/if_ixl.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/if_rtwn.c cvs rdiff -u -r1.704 -r1.705 src/sys/dev/pci/if_wm.c cvs rdiff -u -r1.90 -r1.91 src/sys/dev/pci/if_wpi.c cvs rdiff -u -r1.283 -r1.284 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.161 -r1.162 src/sys/dev/pci/ixgbe/ixv.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/pcmcia/if_malo_pcmcia.c cvs rdiff -u -r1.112 -r1.113 src/sys/dev/scsipi/if_se.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/usb/if_umb.c cvs rdiff -u -r1.41 -r1.42 src/sys/dev/usb/usbnet.c cvs rdiff -u -r1.82 -r1.83 src/sys/net/if_arcsubr.c cvs rdiff -u -r1.179 -r1.180 src/sys/net/if_bridge.c cvs rdiff -u -r1.61 -r1.62 src/sys/net/if_faith.c cvs rdiff -u -r1.154 -r1.155 src/sys/net/if_gif.c cvs rdiff -u -r1.46 -r1.47 src/sys/net/if_l2tp.c cvs rdiff -u -r1.112 -r1.113 src/sys/net/if_loop.c cvs rdiff -u -r1.36 -r1.37 src/sys/net/if_mpls.c cvs rdiff -u -r1.176 -r1.177 src/sys/net/if_pppoe.c cvs rdiff -u -r1.31 -r1.32 src/sys/net/if_srt.c cvs rdiff -u -r1.107 -r1.108 src/sys/net/if_stf.c cvs rdiff -u -r1.121 -r1.122 src/sys/net/if_tap.c cvs rdiff -u -r1.153 -r1.154 src/sys/net/if_vlan.c cvs rdiff -u -r1.63 -r1.64 src/sys/net/if_wg.c cvs rdiff -u -r1.4 -r1.5 src/sys/net/lagg/if_lagg.c cvs rdiff -u -r1.114 -r1.115 src/sys/netinet/ip_carp.c cvs rdiff -u -r1.81 -r1.82 src/sys/rump/net/lib/libshmif/if_shmem.c cvs rdiff -u -r1.58 -r1.59 src/sys/rump/net/lib/libvirtif/if_virt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/man/man4/usbnet.4 diff -u src/share/man/man4/usbnet.4:1.4 src/share/man/man4/usbnet.4:1.5 --- src/share/man/man4/usbnet.4:1.4 Fri Sep 20 10:34:54 2019 +++ src/share/man/man4/usbnet.4 Wed Jun 16 00:21:17 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: usbnet.4,v 1.4 2019/09/20 10:34:54 mrg Exp $ +.\" $NetBSD: usbnet.4,v 1.5 2021/06/16 00:21:17 riastradh Exp $ .\" .\" Copyright (c) 2019 Matthew R. Green .\" All rights reserved. @@ -26,7 +26,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 24, 2019 +.Dd June 15, 2021 .Dt USBNET 4 .Os .Sh NAME @@ -60,8 +60,6 @@ Creation of Rx or Tx list failed, device Time out in transmission. .It "devN: pipe abort failed" Aborting USB pipes after watchdog timeout failed. -.It "devN: if_initialize failed" -Couldn't register network interface, device non-functional. .It "devN: couldn't establish power handler" Call to .Xr pmf_device_register 9 Index: src/sys/arch/arm/broadcom/bcm53xx_eth.c diff -u src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.40 src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.41 --- src/sys/arch/arm/broadcom/bcm53xx_eth.c:1.40 Mon Feb 3 08:00:35 2020 +++ src/sys/arch/arm/broadcom/bcm53xx_eth.c Wed Jun 16 00:21:17 2021 @@ -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, devic /* * 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, devic return; -fail_5: - ifmedia_removeall(&sc->sc_media); fail_4: intr_disestablish(sc->sc_ih); fail_3: Index: src/sys/arch/powerpc/booke/dev/pq3etsec.c diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.54 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.55 --- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.54 Sat Apr 24 23:36:46 2021 +++ src/sys/arch/powerpc/booke/dev/pq3etsec.c Wed Jun 16 00:21:18 2021 @@ -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_ /* * 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_ 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: Index: src/sys/arch/usermode/dev/if_veth.c diff -u src/sys/arch/usermode/dev/if_veth.c:1.14 src/sys/arch/usermode/dev/if_veth.c:1.15 --- src/sys/arch/usermode/dev/if_veth.c:1.14 Wed Feb 5 07:18:16 2020 +++ src/sys/arch/usermode/dev/if_veth.c Wed Jun 16 00:21:18 2021 @@ -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 <jmcne...@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 se 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 se 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); Index: src/sys/dev/hyperv/if_hvn.c diff -u src/sys/dev/hyperv/if_hvn.c:1.20 src/sys/dev/hyperv/if_hvn.c:1.21 --- src/sys/dev/hyperv/if_hvn.c:1.20 Fri Jan 29 04:38:49 2021 +++ src/sys/dev/hyperv/if_hvn.c Wed Jun 16 00:21:18 2021 @@ -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 sel 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 sel 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); Index: src/sys/dev/ic/an.c diff -u src/sys/dev/ic/an.c:1.74 src/sys/dev/ic/an.c:1.75 --- src/sys/dev/ic/an.c:1.74 Fri Jun 11 05:00:41 2021 +++ src/sys/dev/ic/an.c Wed Jun 16 00:21:18 2021 @@ -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 <wp...@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); Index: src/sys/dev/ic/athn.c diff -u src/sys/dev/ic/athn.c:1.24 src/sys/dev/ic/athn.c:1.25 --- src/sys/dev/ic/athn.c:1.24 Sun Nov 15 12:33:53 2020 +++ src/sys/dev/ic/athn.c Wed Jun 16 00:21:18 2021 @@ -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); Index: src/sys/dev/ic/atw.c diff -u src/sys/dev/ic/atw.c:1.170 src/sys/dev/ic/atw.c:1.171 --- src/sys/dev/ic/atw.c:1.170 Wed Jan 29 14:09:58 2020 +++ src/sys/dev/ic/atw.c Wed Jun 16 00:21:18 2021 @@ -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); Index: src/sys/dev/ic/bwfm.c diff -u src/sys/dev/ic/bwfm.c:1.30 src/sys/dev/ic/bwfm.c:1.31 --- src/sys/dev/ic/bwfm.c:1.30 Tue Apr 13 04:13:52 2021 +++ src/sys/dev/ic/bwfm.c Wed Jun 16 00:21:18 2021 @@ -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; Index: src/sys/dev/ic/bwi.c diff -u src/sys/dev/ic/bwi.c:1.37 src/sys/dev/ic/bwi.c:1.38 --- src/sys/dev/ic/bwi.c:1.37 Wed Jan 29 14:14:55 2020 +++ src/sys/dev/ic/bwi.c Wed Jun 16 00:21:18 2021 @@ -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); Index: src/sys/dev/ic/dwc_gmac.c diff -u src/sys/dev/ic/dwc_gmac.c:1.73 src/sys/dev/ic/dwc_gmac.c:1.74 --- src/sys/dev/ic/dwc_gmac.c:1.73 Thu May 13 05:56:39 2021 +++ src/sys/dev/ic/dwc_gmac.c Wed Jun 16 00:21:18 2021 @@ -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 *s 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 *s * 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 *s 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); Index: src/sys/dev/ic/malo.c diff -u src/sys/dev/ic/malo.c:1.18 src/sys/dev/ic/malo.c:1.19 --- src/sys/dev/ic/malo.c:1.18 Wed Jan 29 15:00:39 2020 +++ src/sys/dev/ic/malo.c Wed Jun 16 00:21:18 2021 @@ -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); Index: src/sys/dev/ic/rt2560.c diff -u src/sys/dev/ic/rt2560.c:1.38 src/sys/dev/ic/rt2560.c:1.39 --- src/sys/dev/ic/rt2560.c:1.38 Wed Jan 29 15:06:12 2020 +++ src/sys/dev/ic/rt2560.c Wed Jun 16 00:21:18 2021 @@ -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); Index: src/sys/dev/ic/rt2661.c diff -u src/sys/dev/ic/rt2661.c:1.43 src/sys/dev/ic/rt2661.c:1.44 --- src/sys/dev/ic/rt2661.c:1.43 Wed Jan 29 15:06:12 2020 +++ src/sys/dev/ic/rt2661.c Wed Jun 16 00:21:18 2021 @@ -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]); Index: src/sys/dev/ic/rt2860.c diff -u src/sys/dev/ic/rt2860.c:1.35 src/sys/dev/ic/rt2860.c:1.36 --- src/sys/dev/ic/rt2860.c:1.35 Wed Jan 29 15:06:12 2020 +++ src/sys/dev/ic/rt2860.c Wed Jun 16 00:21:18 2021 @@ -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); Index: src/sys/dev/ic/rtw.c diff -u src/sys/dev/ic/rtw.c:1.135 src/sys/dev/ic/rtw.c:1.136 --- src/sys/dev/ic/rtw.c:1.135 Wed Jan 29 15:06:12 2020 +++ src/sys/dev/ic/rtw.c Wed Jun 16 00:21:18 2021 @@ -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); Index: src/sys/dev/ic/wi.c diff -u src/sys/dev/ic/wi.c:1.255 src/sys/dev/ic/wi.c:1.256 --- src/sys/dev/ic/wi.c:1.255 Thu Jan 30 04:56:11 2020 +++ src/sys/dev/ic/wi.c Wed Jun 16 00:21:18 2021 @@ -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 uin 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 uin /* * 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 uin 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; Index: src/sys/dev/pci/if_aq.c diff -u src/sys/dev/pci/if_aq.c:1.26 src/sys/dev/pci/if_aq.c:1.27 --- src/sys/dev/pci/if_aq.c:1.26 Sun Jun 13 10:05:39 2021 +++ src/sys/dev/pci/if_aq.c Wed Jun 16 00:21:18 2021 @@ -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 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); Index: src/sys/dev/pci/if_iavf.c diff -u src/sys/dev/pci/if_iavf.c:1.13 src/sys/dev/pci/if_iavf.c:1.14 --- src/sys/dev/pci/if_iavf.c:1.13 Fri Mar 5 13:21:07 2021 +++ src/sys/dev/pci/if_iavf.c Wed Jun 16 00:21:18 2021 @@ -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 se 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); Index: src/sys/dev/pci/if_ipw.c diff -u src/sys/dev/pci/if_ipw.c:1.73 src/sys/dev/pci/if_ipw.c:1.74 --- src/sys/dev/pci/if_ipw.c:1.73 Thu Jan 30 06:03:34 2020 +++ src/sys/dev/pci/if_ipw.c Wed Jun 16 00:21:18 2021 @@ -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 sel 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); Index: src/sys/dev/pci/if_iwi.c diff -u src/sys/dev/pci/if_iwi.c:1.115 src/sys/dev/pci/if_iwi.c:1.116 --- src/sys/dev/pci/if_iwi.c:1.115 Sat May 8 00:27:02 2021 +++ src/sys/dev/pci/if_iwi.c Wed Jun 16 00:21:18 2021 @@ -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 sel 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); Index: src/sys/dev/pci/if_iwm.c diff -u src/sys/dev/pci/if_iwm.c:1.85 src/sys/dev/pci/if_iwm.c:1.86 --- src/sys/dev/pci/if_iwm.c:1.85 Fri May 22 20:27:16 2020 +++ src/sys/dev/pci/if_iwm.c Wed Jun 16 00:21:18 2021 @@ -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 sel 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 sel 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); Index: src/sys/dev/pci/if_iwn.c diff -u src/sys/dev/pci/if_iwn.c:1.95 src/sys/dev/pci/if_iwn.c:1.96 --- src/sys/dev/pci/if_iwn.c:1.95 Sat May 8 00:27:02 2021 +++ src/sys/dev/pci/if_iwn.c Wed Jun 16 00:21:18 2021 @@ -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, dev 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, dev 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 Index: src/sys/dev/pci/if_ixl.c diff -u src/sys/dev/pci/if_ixl.c:1.76 src/sys/dev/pci/if_ixl.c:1.77 --- src/sys/dev/pci/if_ixl.c:1.76 Tue Feb 9 15:05:49 2021 +++ src/sys/dev/pci/if_ixl.c Wed Jun 16 00:21:18 2021 @@ -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 sel 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); Index: src/sys/dev/pci/if_rtwn.c diff -u src/sys/dev/pci/if_rtwn.c:1.19 src/sys/dev/pci/if_rtwn.c:1.20 --- src/sys/dev/pci/if_rtwn.c:1.19 Thu Jan 30 06:03:34 2020 +++ src/sys/dev/pci/if_rtwn.c Wed Jun 16 00:21:18 2021 @@ -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 se 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 se 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 Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.704 src/sys/dev/pci/if_wm.c:1.705 --- src/sys/dev/pci/if_wm.c:1.704 Wed May 12 10:16:12 2021 +++ src/sys/dev/pci/if_wm.c Wed Jun 16 00:21:18 2021 @@ -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); Index: src/sys/dev/pci/if_wpi.c diff -u src/sys/dev/pci/if_wpi.c:1.90 src/sys/dev/pci/if_wpi.c:1.91 --- src/sys/dev/pci/if_wpi.c:1.90 Fri Feb 5 16:06:24 2021 +++ src/sys/dev/pci/if_wpi.c Wed Jun 16 00:21:18 2021 @@ -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, dev 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, dev 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]); Index: src/sys/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.283 src/sys/dev/pci/ixgbe/ixgbe.c:1.284 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.283 Tue May 18 05:29:16 2021 +++ src/sys/dev/pci/ixgbe/ixgbe.c Wed Jun 16 00:21:18 2021 @@ -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, stru { 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, stru 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", Index: src/sys/dev/pci/ixgbe/ixv.c diff -u src/sys/dev/pci/ixgbe/ixv.c:1.161 src/sys/dev/pci/ixgbe/ixv.c:1.162 --- src/sys/dev/pci/ixgbe/ixv.c:1.161 Wed May 19 08:19:20 2021 +++ src/sys/dev/pci/ixgbe/ixv.c Wed Jun 16 00:21:18 2021 @@ -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 { 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 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", Index: src/sys/dev/pcmcia/if_malo_pcmcia.c diff -u src/sys/dev/pcmcia/if_malo_pcmcia.c:1.25 src/sys/dev/pcmcia/if_malo_pcmcia.c:1.26 --- src/sys/dev/pcmcia/if_malo_pcmcia.c:1.25 Wed Jan 29 13:54:41 2020 +++ src/sys/dev/pcmcia/if_malo_pcmcia.c Wed Jun 16 00:21:19 2021 @@ -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); } Index: src/sys/dev/scsipi/if_se.c diff -u src/sys/dev/scsipi/if_se.c:1.112 src/sys/dev/scsipi/if_se.c:1.113 --- src/sys/dev/scsipi/if_se.c:1.112 Tue Sep 29 02:58:52 2020 +++ src/sys/dev/scsipi/if_se.c Wed Jun 16 00:21:19 2021 @@ -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.d...@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, 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, Index: src/sys/dev/usb/if_umb.c diff -u src/sys/dev/usb/if_umb.c:1.19 src/sys/dev/usb/if_umb.c:1.20 --- src/sys/dev/usb/if_umb.c:1.19 Tue Mar 24 07:12:16 2020 +++ src/sys/dev/usb/if_umb.c Wed Jun 16 00:21:19 2021 @@ -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 sel 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 sel 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); Index: src/sys/dev/usb/usbnet.c diff -u src/sys/dev/usb/usbnet.c:1.41 src/sys/dev/usb/usbnet.c:1.42 --- src/sys/dev/usb/usbnet.c:1.41 Sun Apr 25 05:15:20 2021 +++ src/sys/dev/usb/usbnet.c Wed Jun 16 00:21:19 2021 @@ -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); Index: src/sys/net/if_arcsubr.c diff -u src/sys/net/if_arcsubr.c:1.82 src/sys/net/if_arcsubr.c:1.83 --- src/sys/net/if_arcsubr.c:1.82 Fri Aug 28 06:23:42 2020 +++ src/sys/net/if_arcsubr.c Wed Jun 16 00:21:19 2021 @@ -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 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); Index: src/sys/net/if_bridge.c diff -u src/sys/net/if_bridge.c:1.179 src/sys/net/if_bridge.c:1.180 --- src/sys/net/if_bridge.c:1.179 Fri Feb 19 14:51:59 2021 +++ src/sys/net/if_bridge.c Wed Jun 16 00:21:19 2021 @@ -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 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. Index: src/sys/net/if_faith.c diff -u src/sys/net/if_faith.c:1.61 src/sys/net/if_faith.c:1.62 --- src/sys/net/if_faith.c:1.61 Wed Jan 29 04:18:34 2020 +++ src/sys/net/if_faith.c Wed Jun 16 00:21:19 2021 @@ -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, 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); Index: src/sys/net/if_gif.c diff -u src/sys/net/if_gif.c:1.154 src/sys/net/if_gif.c:1.155 --- src/sys/net/if_gif.c:1.154 Wed Oct 14 15:22:17 2020 +++ src/sys/net/if_gif.c Wed Jun 16 00:21:19 2021 @@ -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, i 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); Index: src/sys/net/if_l2tp.c diff -u src/sys/net/if_l2tp.c:1.46 src/sys/net/if_l2tp.c:1.47 --- src/sys/net/if_l2tp.c:1.46 Sun Oct 25 08:18:39 2020 +++ src/sys/net/if_l2tp.c Wed Jun 16 00:21:19 2021 @@ -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 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)); Index: src/sys/net/if_loop.c diff -u src/sys/net/if_loop.c:1.112 src/sys/net/if_loop.c:1.113 --- src/sys/net/if_loop.c:1.112 Wed Oct 14 16:10:32 2020 +++ src/sys/net/if_loop.c Wed Jun 16 00:21:19 2021 @@ -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, 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)); Index: src/sys/net/if_mpls.c diff -u src/sys/net/if_mpls.c:1.36 src/sys/net/if_mpls.c:1.37 --- src/sys/net/if_mpls.c:1.36 Wed Jan 29 04:18:34 2020 +++ src/sys/net/if_mpls.c Wed Jun 16 00:21:19 2021 @@ -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, 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; Index: src/sys/net/if_pppoe.c diff -u src/sys/net/if_pppoe.c:1.176 src/sys/net/if_pppoe.c:1.177 --- src/sys/net/if_pppoe.c:1.176 Wed May 19 03:44:46 2021 +++ src/sys/net/if_pppoe.c Wed Jun 16 00:21:19 2021 @@ -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, 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, 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)); Index: src/sys/net/if_srt.c diff -u src/sys/net/if_srt.c:1.31 src/sys/net/if_srt.c:1.32 --- src/sys/net/if_srt.c:1.31 Wed Jan 29 04:28:27 2020 +++ src/sys/net/if_srt.c Wed Jun 16 00:21:19 2021 @@ -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, in 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); Index: src/sys/net/if_stf.c diff -u src/sys/net/if_stf.c:1.107 src/sys/net/if_stf.c:1.108 --- src/sys/net/if_stf.c:1.107 Wed Jan 29 04:28:27 2020 +++ src/sys/net/if_stf.c Wed Jun 16 00:21:19 2021 @@ -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, i 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); Index: src/sys/net/if_tap.c diff -u src/sys/net/if_tap.c:1.121 src/sys/net/if_tap.c:1.122 --- src/sys/net/if_tap.c:1.121 Fri Dec 18 01:31:49 2020 +++ src/sys/net/if_tap.c Wed Jun 16 00:21:19 2021 @@ -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 sel 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. */ Index: src/sys/net/if_vlan.c diff -u src/sys/net/if_vlan.c:1.153 src/sys/net/if_vlan.c:1.154 --- src/sys/net/if_vlan.c:1.153 Sat Sep 26 18:38:09 2020 +++ src/sys/net/if_vlan.c Wed Jun 16 00:21:19 2021 @@ -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, 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, 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, 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 Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.63 src/sys/net/if_wg.c:1.64 --- src/sys/net/if_wg.c:1.63 Thu Apr 29 17:55:51 2021 +++ src/sys/net/if_wg.c Wed Jun 16 00:21:19 2021 @@ -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.ry...@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 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); Index: src/sys/net/lagg/if_lagg.c diff -u src/sys/net/lagg/if_lagg.c:1.4 src/sys/net/lagg/if_lagg.c:1.5 --- src/sys/net/lagg/if_lagg.c:1.4 Mon May 24 13:42:58 2021 +++ src/sys/net/lagg/if_lagg.c Wed Jun 16 00:21:19 2021 @@ -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 <r...@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, 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, 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); Index: src/sys/netinet/ip_carp.c diff -u src/sys/netinet/ip_carp.c:1.114 src/sys/netinet/ip_carp.c:1.115 --- src/sys/netinet/ip_carp.c:1.114 Wed Oct 14 13:43:56 2020 +++ src/sys/netinet/ip_carp.c Wed Jun 16 00:21:19 2021 @@ -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, 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, 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; Index: src/sys/rump/net/lib/libshmif/if_shmem.c diff -u src/sys/rump/net/lib/libshmif/if_shmem.c:1.81 src/sys/rump/net/lib/libshmif/if_shmem.c:1.82 --- src/sys/rump/net/lib/libshmif/if_shmem.c:1.81 Tue Feb 25 03:26:18 2020 +++ src/sys/rump/net/lib/libshmif/if_shmem.c Wed Jun 16 00:21:19 2021 @@ -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 Index: src/sys/rump/net/lib/libvirtif/if_virt.c diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.58 src/sys/rump/net/lib/libvirtif/if_virt.c:1.59 --- src/sys/rump/net/lib/libvirtif/if_virt.c:1.58 Sat Feb 1 22:45:01 2020 +++ src/sys/rump/net/lib/libvirtif/if_virt.c Wed Jun 16 00:21:20 2021 @@ -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 n 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 n 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; }