git: f500e5c6c99b - stable/13 - net: Remove unneeded NULL check for the allocated ifnet
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 08 Oct 2024 10:09:18 UTC
The branch stable/13 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=f500e5c6c99bd4520daa4524113462e3cf68f032 commit f500e5c6c99bd4520daa4524113462e3cf68f032 Author: Zhenlei Huang <zlei@FreeBSD.org> AuthorDate: 2024-06-28 10:16:29 +0000 Commit: Zhenlei Huang <zlei@FreeBSD.org> CommitDate: 2024-10-08 10:07:18 +0000 net: Remove unneeded NULL check for the allocated ifnet Change 4787572d0580 made if_alloc_domain() never fail, then also do the wrappers if_alloc(), if_alloc_dev(), and if_gethandle(). No functional change intended. Reviewed by: kp, imp, glebius, stevek MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D45740 MFC note: This is only a partial MFC, as some drivers do not exist in stable/13 branch. The if_epair(4) drifts too much from stable/14 so not included in this MFC. (cherry picked from commit aa3860851b9f6a6002d135b1cac7736e0995eedc) (cherry picked from commit 6b1f530935c5f84ec65dad87b7c20c6b7a72a6d3) --- sys/arm/allwinner/if_emac.c | 5 ----- sys/arm/ti/cpsw/if_cpsw.c | 5 ----- sys/dev/ae/if_ae.c | 6 ------ sys/dev/age/if_age.c | 6 ------ sys/dev/alc/if_alc.c | 6 ------ sys/dev/ale/if_ale.c | 6 ------ sys/dev/altera/atse/if_atse.c | 5 ----- sys/dev/axgbe/if_axgbe.c | 5 ----- sys/dev/bce/if_bce.c | 6 ------ sys/dev/bfe/if_bfe.c | 5 ----- sys/dev/bge/if_bge.c | 5 ----- sys/dev/bxe/bxe.c | 16 +++------------- sys/dev/cadence/if_cgem.c | 5 ----- sys/dev/cas/if_cas.c | 2 -- sys/dev/cxgb/cxgb_main.c | 5 ----- sys/dev/cxgbe/t4_main.c | 21 +++++---------------- sys/dev/cxgbe/t4_tracer.c | 6 ------ sys/dev/dc/if_dc.c | 5 ----- sys/dev/dpaa/if_dtsec.c | 6 ------ sys/dev/dpaa2/dpaa2_ni.c | 5 ----- sys/dev/ena/ena.c | 17 +++-------------- sys/dev/et/if_et.c | 5 ----- sys/dev/etherswitch/arswitch/arswitch.c | 6 ------ sys/dev/etherswitch/e6000sw/e6000sw.c | 2 -- sys/dev/etherswitch/e6000sw/e6060sw.c | 6 ------ sys/dev/etherswitch/infineon/adm6996fc.c | 6 ------ sys/dev/etherswitch/ip17x/ip17x.c | 6 ------ sys/dev/etherswitch/micrel/ksz8995ma.c | 6 ------ sys/dev/etherswitch/mtkswitch/mtkswitch.c | 6 ------ sys/dev/etherswitch/rtl8366/rtl8366rb.c | 6 ------ sys/dev/etherswitch/ukswitch/ukswitch.c | 6 ------ sys/dev/firewire/if_fwe.c | 7 +------ sys/dev/firewire/if_fwip.c | 4 +--- sys/dev/fxp/if_fxp.c | 5 ----- sys/dev/gem/if_gem.c | 2 -- sys/dev/gve/gve_main.c | 13 ++----------- sys/dev/iicbus/if_ic.c | 2 -- sys/dev/jme/if_jme.c | 6 ------ sys/dev/le/lance.c | 2 -- sys/dev/lge/if_lge.c | 5 ----- sys/dev/liquidio/lio_main.c | 5 ----- sys/dev/mge/if_mge.c | 6 ------ sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c | 5 ----- sys/dev/mlx5/mlx5_en/mlx5_en_main.c | 6 ------ sys/dev/msk/if_msk.c | 5 ----- sys/dev/mxge/if_mxge.c | 6 ------ sys/dev/my/if_my.c | 6 ------ sys/dev/neta/if_mvneta.c | 5 ----- sys/dev/netmap/if_ptnet.c | 6 ------ sys/dev/netmap/netmap_freebsd.c | 4 ---- sys/dev/nfe/if_nfe.c | 5 ----- sys/dev/nge/if_nge.c | 5 ----- sys/dev/ntb/if_ntb/if_ntb.c | 4 ---- sys/dev/oce/oce_if.c | 13 +++---------- sys/dev/ppbus/if_plip.c | 4 ---- sys/dev/qlnx/qlnxe/qlnx_os.c | 4 ---- sys/dev/qlxgb/qla_os.c | 3 --- sys/dev/qlxgbe/ql_os.c | 4 ---- sys/dev/qlxge/qls_os.c | 4 ---- sys/dev/re/if_re.c | 5 ----- sys/dev/rl/if_rl.c | 5 ----- sys/dev/sbni/if_sbni.c | 5 +---- sys/dev/sbni/if_sbni_isa.c | 7 +------ sys/dev/sbni/if_sbni_pci.c | 17 +++-------------- sys/dev/sbni/if_sbnivar.h | 2 +- sys/dev/sfxge/sfxge.c | 7 ------- sys/dev/sge/if_sge.c | 5 ----- sys/dev/sis/if_sis.c | 5 ----- sys/dev/sk/if_sk.c | 5 ----- sys/dev/smc/if_smc.c | 4 ---- sys/dev/ste/if_ste.c | 5 ----- sys/dev/stge/if_stge.c | 6 ------ sys/dev/sume/if_sume.c | 16 +++------------- sys/dev/ti/if_ti.c | 5 ----- sys/dev/tsec/if_tsec.c | 6 ------ sys/dev/usb/net/if_usie.c | 5 ----- sys/dev/usb/net/uhso.c | 4 ---- sys/dev/usb/net/usb_ethernet.c | 5 ----- sys/dev/usb/usb_pf.c | 6 ------ sys/dev/vge/if_vge.c | 6 ------ sys/dev/virtio/network/if_vtnet.c | 16 +++------------- sys/dev/vnic/nicvf_main.c | 17 +++-------------- sys/dev/vnic/thunder_mdio.c | 4 ---- sys/dev/vr/if_vr.c | 5 ----- sys/dev/vte/if_vte.c | 6 ------ sys/dev/xilinx/if_xae.c | 5 ----- sys/dev/xl/if_xl.c | 5 ----- sys/net/if_bridge.c | 4 ---- sys/net/if_disc.c | 5 ----- sys/net/if_edsc.c | 5 ----- sys/net/if_enc.c | 4 ---- sys/net/if_lagg.c | 4 ---- sys/net/if_loop.c | 3 --- sys/net/if_stf.c | 5 ----- sys/net/if_tuntap.c | 3 --- sys/net/if_vlan.c | 8 -------- sys/net/if_vxlan.c | 4 ---- sys/net/iflib.c | 4 ---- sys/net80211/ieee80211.c | 4 ---- sys/netgraph/ng_eiface.c | 5 ----- sys/netgraph/ng_iface.c | 4 ---- sys/netpfil/ipfw/ip_fw_bpf.c | 4 ---- sys/netpfil/pf/if_pflog.c | 3 --- sys/netpfil/pf/if_pfsync.c | 4 ---- sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 ---- 105 files changed, 33 insertions(+), 582 deletions(-) diff --git a/sys/arm/allwinner/if_emac.c b/sys/arm/allwinner/if_emac.c index ce53e075c196..5752582c3fa2 100644 --- a/sys/arm/allwinner/if_emac.c +++ b/sys/arm/allwinner/if_emac.c @@ -942,11 +942,6 @@ emac_attach(device_t dev) emac_reset(sc); ifp = sc->emac_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "unable to allocate ifp\n"); - error = ENOSPC; - goto fail; - } ifp->if_softc = sc; /* Setup MII */ diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c index 81c2e29e0f8c..9ab73cd62527 100644 --- a/sys/arm/ti/cpsw/if_cpsw.c +++ b/sys/arm/ti/cpsw/if_cpsw.c @@ -1029,11 +1029,6 @@ cpswp_attach(device_t dev) /* Allocate network interface */ ifp = sc->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - cpswp_detach(dev); - return (ENXIO); - } - if_initname(ifp, device_get_name(sc->dev), sc->unit); ifp->if_softc = sc; ifp->if_flags = IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST; diff --git a/sys/dev/ae/if_ae.c b/sys/dev/ae/if_ae.c index f8e83dc3c563..a85100daa8f1 100644 --- a/sys/dev/ae/if_ae.c +++ b/sys/dev/ae/if_ae.c @@ -328,12 +328,6 @@ ae_attach(device_t dev) goto fail; ifp = sc->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "could not allocate ifnet structure.\n"); - error = ENXIO; - goto fail; - } - ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; diff --git a/sys/dev/age/if_age.c b/sys/dev/age/if_age.c index 7bb494d81de2..cd589dcb734d 100644 --- a/sys/dev/age/if_age.c +++ b/sys/dev/age/if_age.c @@ -593,12 +593,6 @@ age_attach(device_t dev) age_get_macaddr(sc); ifp = sc->age_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "cannot allocate ifnet structure.\n"); - error = ENXIO; - goto fail; - } - ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; diff --git a/sys/dev/alc/if_alc.c b/sys/dev/alc/if_alc.c index c4e66fe8e1be..e6c0470d48c7 100644 --- a/sys/dev/alc/if_alc.c +++ b/sys/dev/alc/if_alc.c @@ -1565,12 +1565,6 @@ alc_attach(device_t dev) alc_get_macaddr(sc); ifp = sc->alc_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "cannot allocate ifnet structure.\n"); - error = ENXIO; - goto fail; - } - ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; diff --git a/sys/dev/ale/if_ale.c b/sys/dev/ale/if_ale.c index a04d9dc651d3..8b170c2f99a7 100644 --- a/sys/dev/ale/if_ale.c +++ b/sys/dev/ale/if_ale.c @@ -612,12 +612,6 @@ ale_attach(device_t dev) ale_get_macaddr(sc); ifp = sc->ale_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "cannot allocate ifnet structure.\n"); - error = ENXIO; - goto fail; - } - ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; diff --git a/sys/dev/altera/atse/if_atse.c b/sys/dev/altera/atse/if_atse.c index b13c1ca8c563..e7209780f838 100644 --- a/sys/dev/altera/atse/if_atse.c +++ b/sys/dev/altera/atse/if_atse.c @@ -1374,11 +1374,6 @@ atse_attach(device_t dev) /* Setup interface. */ ifp = sc->atse_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "if_alloc() failed\n"); - error = ENOSPC; - goto err; - } ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; diff --git a/sys/dev/axgbe/if_axgbe.c b/sys/dev/axgbe/if_axgbe.c index 89d187801e3c..926f10826cfb 100644 --- a/sys/dev/axgbe/if_axgbe.c +++ b/sys/dev/axgbe/if_axgbe.c @@ -389,11 +389,6 @@ axgbe_attach(device_t dev) OF_getprop(node, "mac-address", sc->mac_addr, ETHER_ADDR_LEN); sc->prv.netdev = ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "Cannot alloc ifnet\n"); - return (ENXIO); - } - sc->prv.dev = dev; sc->prv.dmat = bus_get_dma_tag(dev); sc->prv.phy.advertising = ADVERTISED_10000baseKR_Full | diff --git a/sys/dev/bce/if_bce.c b/sys/dev/bce/if_bce.c index 322ab8328080..721db7ff592b 100644 --- a/sys/dev/bce/if_bce.c +++ b/sys/dev/bce/if_bce.c @@ -1363,12 +1363,6 @@ bce_attach(device_t dev) /* Allocate an ifnet structure. */ ifp = sc->bce_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - BCE_PRINTF("%s(%d): Interface allocation failed!\n", - __FILE__, __LINE__); - rc = ENXIO; - goto bce_attach_fail; - } /* Initialize the ifnet interface. */ ifp->if_softc = sc; diff --git a/sys/dev/bfe/if_bfe.c b/sys/dev/bfe/if_bfe.c index 42dfcd26eabf..40aee47d2172 100644 --- a/sys/dev/bfe/if_bfe.c +++ b/sys/dev/bfe/if_bfe.c @@ -480,11 +480,6 @@ bfe_attach(device_t dev) /* Set up ifnet structure */ ifp = sc->bfe_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "failed to if_alloc()\n"); - error = ENOSPC; - goto fail; - } ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 91b33492b2d2..f84a16b5fc85 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -3714,11 +3714,6 @@ bge_attach(device_t dev) /* Set up ifnet structure */ ifp = sc->bge_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(sc->bge_dev, "failed to if_alloc()\n"); - error = ENXIO; - goto fail; - } if_setsoftc(ifp, sc); if_initname(ifp, device_get_name(dev), device_get_unit(dev)); if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c index cfe642eafeb2..daed2ea9e5e4 100644 --- a/sys/dev/bxe/bxe.c +++ b/sys/dev/bxe/bxe.c @@ -12989,7 +12989,7 @@ bxe_init(void *xsc) BXE_CORE_UNLOCK(sc); } -static int +static void bxe_init_ifnet(struct bxe_softc *sc) { if_t ifp; @@ -13009,10 +13009,7 @@ bxe_init_ifnet(struct bxe_softc *sc) BLOGI(sc, "IFMEDIA flags : %x\n", sc->ifmedia.ifm_media); /* allocate the ifnet structure */ - if ((ifp = if_gethandle(IFT_ETHER)) == NULL) { - BLOGE(sc, "Interface allocation failed!\n"); - return (ENXIO); - } + ifp = if_gethandle(IFT_ETHER); if_setsoftc(ifp, sc); if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev)); @@ -13058,8 +13055,6 @@ bxe_init_ifnet(struct bxe_softc *sc) /* Attach driver debugnet methods. */ DEBUGNET_SET(ifp, bxe); - - return (0); } static void @@ -16285,12 +16280,7 @@ bxe_attach(device_t dev) bxe_get_phy_info(sc); /* initialize the FreeBSD ifnet interface */ - if (bxe_init_ifnet(sc) != 0) { - bxe_release_mutexes(sc); - bxe_deallocate_bars(sc); - pci_disable_busmaster(dev); - return (ENXIO); - } + bxe_init_ifnet(sc); if (bxe_add_cdev(sc) != 0) { if (sc->ifp != NULL) { diff --git a/sys/dev/cadence/if_cgem.c b/sys/dev/cadence/if_cgem.c index b6a06618ed1d..66433e0f089e 100644 --- a/sys/dev/cadence/if_cgem.c +++ b/sys/dev/cadence/if_cgem.c @@ -1786,11 +1786,6 @@ cgem_attach(device_t dev) /* Set up ifnet structure. */ ifp = sc->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "could not allocate ifnet structure\n"); - cgem_detach(dev); - return (ENOMEM); - } if_setsoftc(ifp, sc); if_initname(ifp, IF_CGEM_NAME, device_get_unit(dev)); if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); diff --git a/sys/dev/cas/if_cas.c b/sys/dev/cas/if_cas.c index 8071635c20e0..c45438ec539a 100644 --- a/sys/dev/cas/if_cas.c +++ b/sys/dev/cas/if_cas.c @@ -190,8 +190,6 @@ cas_attach(struct cas_softc *sc) /* Set up ifnet structure. */ ifp = sc->sc_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) - return (ENOSPC); ifp->if_softc = sc; if_initname(ifp, device_get_name(sc->sc_dev), device_get_unit(sc->sc_dev)); diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c index 8c817d751cdc..cf10effeb089 100644 --- a/sys/dev/cxgb/cxgb_main.c +++ b/sys/dev/cxgb/cxgb_main.c @@ -1018,11 +1018,6 @@ cxgb_port_attach(device_t dev) /* Allocate an ifnet object and set it up */ ifp = p->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "Cannot allocate ifnet\n"); - return (ENOMEM); - } - if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_init = cxgb_init; ifp->if_softc = p; diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 7f949ad8e66c..17969d45ff0c 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -2551,7 +2551,7 @@ cxgbe_probe(device_t dev) IFCAP_HWRXTSTMP | IFCAP_MEXTPG) #define T4_CAP_ENABLE (T4_CAP) -static int +static void cxgbe_vi_attach(device_t dev, struct vi_info *vi) { struct ifnet *ifp; @@ -2590,10 +2590,6 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi) /* Allocate an ifnet and set it up */ ifp = if_alloc_dev(IFT_ETHER, dev); - if (ifp == NULL) { - device_printf(dev, "Cannot allocate ifnet\n"); - return (ENOMEM); - } vi->ifp = ifp; ifp->if_softc = vi; @@ -2699,8 +2695,6 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi) pa.pa_type = PFIL_TYPE_ETHERNET; pa.pa_headname = ifp->if_xname; vi->pfil = pfil_head_register(&pa); - - return (0); } static int @@ -2709,13 +2703,11 @@ cxgbe_attach(device_t dev) struct port_info *pi = device_get_softc(dev); struct adapter *sc = pi->adapter; struct vi_info *vi; - int i, rc; + int i; sysctl_ctx_init(&pi->ctx); - rc = cxgbe_vi_attach(dev, &pi->vi[0]); - if (rc) - return (rc); + cxgbe_vi_attach(dev, &pi->vi[0]); for_each_vi(pi, i, vi) { if (i == 0) @@ -3646,11 +3638,8 @@ vcxgbe_attach(device_t dev) if (rc) return (rc); - rc = cxgbe_vi_attach(dev, vi); - if (rc) { - t4_free_vi(sc, sc->mbox, sc->pf, 0, vi->viid); - return (rc); - } + cxgbe_vi_attach(dev, vi); + return (0); } diff --git a/sys/dev/cxgbe/t4_tracer.c b/sys/dev/cxgbe/t4_tracer.c index adb6d89b6362..92d440d92612 100644 --- a/sys/dev/cxgbe/t4_tracer.c +++ b/sys/dev/cxgbe/t4_tracer.c @@ -173,12 +173,6 @@ t4_cloner_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) goto done; ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - ifc_free_unit(ifc, unit); - rc = ENOMEM; - goto done; - } - /* Note that if_xname is not <if_dname><if_dunit>. */ strlcpy(ifp->if_xname, name, sizeof(ifp->if_xname)); ifp->if_dname = t4_cloner_name; diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index aa8d6790ab9b..7956baff7def 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -2383,11 +2383,6 @@ dc_attach(device_t dev) goto fail; ifp = sc->dc_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not if_alloc()\n"); - error = ENOSPC; - goto fail; - } ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; diff --git a/sys/dev/dpaa/if_dtsec.c b/sys/dev/dpaa/if_dtsec.c index 68a321cbe2bf..7f80b00941aa 100644 --- a/sys/dev/dpaa/if_dtsec.c +++ b/sys/dev/dpaa/if_dtsec.c @@ -678,12 +678,6 @@ dtsec_attach(device_t dev) /* Create network interface for upper layers */ ifp = sc->sc_ifnet = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(sc->sc_dev, "if_alloc() failed.\n"); - dtsec_detach(dev); - return (ENOMEM); - } - ifp->if_softc = sc; ifp->if_mtu = ETHERMTU; /* TODO: Configure */ ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST; diff --git a/sys/dev/dpaa2/dpaa2_ni.c b/sys/dev/dpaa2/dpaa2_ni.c index ed9e641f0793..7d6c70ff3b6b 100644 --- a/sys/dev/dpaa2/dpaa2_ni.c +++ b/sys/dev/dpaa2/dpaa2_ni.c @@ -573,11 +573,6 @@ dpaa2_ni_attach(device_t dev) /* Allocate network interface */ ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "%s: failed to allocate network interface\n", - __func__); - return (ENXIO); - } sc->ifp = ifp; if_initname(ifp, DPAA2_NI_IFNAME, device_get_unit(sc->dev)); diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index fd4bca93ad93..934970ea0cf7 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -148,7 +148,7 @@ static int ena_ioctl(if_t, u_long, caddr_t); static int ena_get_dev_offloads(struct ena_com_dev_get_features_ctx *); static void ena_update_host_info(struct ena_admin_host_info *, if_t); static void ena_update_hwassist(struct ena_adapter *); -static int ena_setup_ifnet(device_t, struct ena_adapter *, +static void ena_setup_ifnet(device_t, struct ena_adapter *, struct ena_com_dev_get_features_ctx *); static int ena_enable_wc(device_t, struct resource *); static int ena_set_queues_placement_policy(device_t, struct ena_com_dev *, @@ -2462,7 +2462,7 @@ ena_update_hwassist(struct ena_adapter *adapter) if_sethwassistbits(ifp, flags, 0); } -static int +static void ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter, struct ena_com_dev_get_features_ctx *feat) { @@ -2470,10 +2470,6 @@ ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter, int caps = 0; ifp = adapter->ifp = if_gethandle(IFT_ETHER); - if (unlikely(ifp == NULL)) { - ena_log(pdev, ERR, "can not allocate ifnet structure\n"); - return (ENXIO); - } if_initname(ifp, device_get_name(pdev), device_get_unit(pdev)); if_setdev(ifp, pdev); if_setsoftc(ifp, adapter); @@ -2517,8 +2513,6 @@ ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter, ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); ether_ifattach(ifp, adapter->mac_addr); - - return (0); } void @@ -3812,11 +3806,7 @@ ena_attach(device_t pdev) ena_sysctl_add_nodes(adapter); /* setup network interface */ - rc = ena_setup_ifnet(pdev, adapter, &get_feat_ctx); - if (unlikely(rc != 0)) { - ena_log(pdev, ERR, "Error with network interface setup\n"); - goto err_customer_metrics_alloc; - } + ena_setup_ifnet(pdev, adapter, &get_feat_ctx); /* Initialize reset task queue */ TASK_INIT(&adapter->reset_task, 0, ena_reset_task, adapter); @@ -3853,7 +3843,6 @@ ena_attach(device_t pdev) err_detach: ether_ifdetach(adapter->ifp); #endif /* DEV_NETMAP */ -err_customer_metrics_alloc: free(adapter->customer_metrics_array, M_DEVBUF); err_metrics_buffer_destroy: ena_com_delete_customer_metrics_buffer(ena_dev); diff --git a/sys/dev/et/if_et.c b/sys/dev/et/if_et.c index bfb205c09e94..08c4ff915840 100644 --- a/sys/dev/et/if_et.c +++ b/sys/dev/et/if_et.c @@ -234,11 +234,6 @@ et_attach(device_t dev) callout_init_mtx(&sc->sc_tick, &sc->sc_mtx, 0); ifp = sc->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not if_alloc()\n"); - error = ENOSPC; - goto fail; - } /* * Initialize tunables diff --git a/sys/dev/etherswitch/arswitch/arswitch.c b/sys/dev/etherswitch/arswitch/arswitch.c index f25f053e9b82..57f7e7908414 100644 --- a/sys/dev/etherswitch/arswitch/arswitch.c +++ b/sys/dev/etherswitch/arswitch/arswitch.c @@ -175,12 +175,6 @@ arswitch_attach_phys(struct arswitch_softc *sc) snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev)); for (phy = 0; phy < sc->numphys; phy++) { sc->ifp[phy] = if_alloc(IFT_ETHER); - if (sc->ifp[phy] == NULL) { - device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); - err = ENOMEM; - break; - } - sc->ifp[phy]->if_softc = sc; sc->ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; diff --git a/sys/dev/etherswitch/e6000sw/e6000sw.c b/sys/dev/etherswitch/e6000sw/e6000sw.c index d309f862a810..8e6049707463 100644 --- a/sys/dev/etherswitch/e6000sw/e6000sw.c +++ b/sys/dev/etherswitch/e6000sw/e6000sw.c @@ -365,8 +365,6 @@ e6000sw_init_interface(e6000sw_softc_t *sc, int port) snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->dev)); sc->ifp[port] = if_alloc(IFT_ETHER); - if (sc->ifp[port] == NULL) - return (ENOMEM); sc->ifp[port]->if_softc = sc; sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; diff --git a/sys/dev/etherswitch/e6000sw/e6060sw.c b/sys/dev/etherswitch/e6000sw/e6060sw.c index c464ebd8c0ce..209b64cbd6de 100644 --- a/sys/dev/etherswitch/e6000sw/e6060sw.c +++ b/sys/dev/etherswitch/e6000sw/e6060sw.c @@ -216,12 +216,6 @@ e6060sw_attach_phys(struct e6060sw_softc *sc) sc->ifpport[phy] = port; sc->portphy[port] = phy; sc->ifp[port] = if_alloc(IFT_ETHER); - if (sc->ifp[port] == NULL) { - device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); - err = ENOMEM; - break; - } - sc->ifp[port]->if_softc = sc; sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; diff --git a/sys/dev/etherswitch/infineon/adm6996fc.c b/sys/dev/etherswitch/infineon/adm6996fc.c index 9acc513a02b7..399ca853af1f 100644 --- a/sys/dev/etherswitch/infineon/adm6996fc.c +++ b/sys/dev/etherswitch/infineon/adm6996fc.c @@ -173,12 +173,6 @@ adm6996fc_attach_phys(struct adm6996fc_softc *sc) sc->ifpport[phy] = port; sc->portphy[port] = phy; sc->ifp[port] = if_alloc(IFT_ETHER); - if (sc->ifp[port] == NULL) { - device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); - err = ENOMEM; - break; - } - sc->ifp[port]->if_softc = sc; sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; diff --git a/sys/dev/etherswitch/ip17x/ip17x.c b/sys/dev/etherswitch/ip17x/ip17x.c index cf118b0bc2cf..e22d785e6572 100644 --- a/sys/dev/etherswitch/ip17x/ip17x.c +++ b/sys/dev/etherswitch/ip17x/ip17x.c @@ -172,12 +172,6 @@ ip17x_attach_phys(struct ip17x_softc *sc) sc->phyport[phy] = port; sc->portphy[port] = phy; sc->ifp[port] = if_alloc(IFT_ETHER); - if (sc->ifp[port] == NULL) { - device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); - err = ENOMEM; - break; - } - sc->ifp[port]->if_softc = sc; sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; diff --git a/sys/dev/etherswitch/micrel/ksz8995ma.c b/sys/dev/etherswitch/micrel/ksz8995ma.c index 737c3f7a50f3..a151a488e527 100644 --- a/sys/dev/etherswitch/micrel/ksz8995ma.c +++ b/sys/dev/etherswitch/micrel/ksz8995ma.c @@ -219,12 +219,6 @@ ksz8995ma_attach_phys(struct ksz8995ma_softc *sc) sc->ifpport[phy] = port; sc->portphy[port] = phy; sc->ifp[port] = if_alloc(IFT_ETHER); - if (sc->ifp[port] == NULL) { - device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); - err = ENOMEM; - break; - } - sc->ifp[port]->if_softc = sc; sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; diff --git a/sys/dev/etherswitch/mtkswitch/mtkswitch.c b/sys/dev/etherswitch/mtkswitch/mtkswitch.c index 292fc8e0ee3a..af774da4eba7 100644 --- a/sys/dev/etherswitch/mtkswitch/mtkswitch.c +++ b/sys/dev/etherswitch/mtkswitch/mtkswitch.c @@ -121,12 +121,6 @@ mtkswitch_attach_phys(struct mtkswitch_softc *sc) continue; } sc->ifp[phy] = if_alloc(IFT_ETHER); - if (sc->ifp[phy] == NULL) { - device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); - err = ENOMEM; - break; - } - sc->ifp[phy]->if_softc = sc; sc->ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; diff --git a/sys/dev/etherswitch/rtl8366/rtl8366rb.c b/sys/dev/etherswitch/rtl8366/rtl8366rb.c index 65682973621a..b8ab134ff828 100644 --- a/sys/dev/etherswitch/rtl8366/rtl8366rb.c +++ b/sys/dev/etherswitch/rtl8366/rtl8366rb.c @@ -238,12 +238,6 @@ rtl8366rb_attach(device_t dev) /* PHYs need an interface, so we generate a dummy one */ for (i = 0; i < sc->numphys; i++) { sc->ifp[i] = if_alloc(IFT_ETHER); - if (sc->ifp[i] == NULL) { - device_printf(dev, "couldn't allocate ifnet structure\n"); - err = ENOMEM; - break; - } - sc->ifp[i]->if_softc = sc; sc->ifp[i]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; diff --git a/sys/dev/etherswitch/ukswitch/ukswitch.c b/sys/dev/etherswitch/ukswitch/ukswitch.c index ab22ac5f97e9..5e0f4c4f350c 100644 --- a/sys/dev/etherswitch/ukswitch/ukswitch.c +++ b/sys/dev/etherswitch/ukswitch/ukswitch.c @@ -124,12 +124,6 @@ ukswitch_attach_phys(struct ukswitch_softc *sc) sc->ifpport[phy] = port; sc->portphy[port] = phy; sc->ifp[port] = if_alloc(IFT_ETHER); - if (sc->ifp[port] == NULL) { - device_printf(sc->sc_dev, "couldn't allocate ifnet structure\n"); - err = ENOMEM; - break; - } - sc->ifp[port]->if_softc = sc; sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING | IFF_SIMPLEX; diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c index 22fdbe503001..7add1c38678c 100644 --- a/sys/dev/firewire/if_fwe.c +++ b/sys/dev/firewire/if_fwe.c @@ -178,12 +178,7 @@ fwe_attach(device_t dev) /* fill the rest and attach interface */ ifp = fwe->eth_softc.ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not if_alloc()\n"); - return (ENOSPC); - } ifp->if_softc = &fwe->eth_softc; - if_initname(ifp, device_get_name(dev), unit); ifp->if_init = fwe_init; ifp->if_start = fwe_start; @@ -201,7 +196,7 @@ fwe_attach(device_t dev) ifp->if_capenable |= IFCAP_VLAN_MTU; FWEDEBUG(ifp, "interface created\n"); - return 0; + return (0); } static void diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c index 89b34aab4257..df258a64d2b6 100644 --- a/sys/dev/firewire/if_fwip.c +++ b/sys/dev/firewire/if_fwip.c @@ -153,8 +153,6 @@ fwip_attach(device_t dev) fwip = ((struct fwip_softc *)device_get_softc(dev)); unit = device_get_unit(dev); ifp = fwip->fw_softc.fwip_ifp = if_alloc(IFT_IEEE1394); - if (ifp == NULL) - return (ENOSPC); mtx_init(&fwip->mtx, "fwip", NULL, MTX_DEF); /* XXX */ @@ -199,7 +197,7 @@ fwip_attach(device_t dev) splx(s); FWIPDEBUG(ifp, "interface created\n"); - return 0; + return (0); } static void diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 1b35a8552b42..7ce47dfee8e4 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -446,11 +446,6 @@ fxp_attach(device_t dev) fxp_serial_ifmedia_sts); ifp = sc->ifp = if_gethandle(IFT_ETHER); - if (ifp == (void *)NULL) { - device_printf(dev, "can not if_alloc()\n"); - error = ENOSPC; - goto fail; - } /* * Enable bus mastering. diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c index ace7d482e6fb..75ee9773eeca 100644 --- a/sys/dev/gem/if_gem.c +++ b/sys/dev/gem/if_gem.c @@ -153,8 +153,6 @@ gem_attach(struct gem_softc *sc) /* Set up ifnet structure. */ ifp = sc->sc_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) - return (ENOSPC); sc->sc_csum_features = GEM_CSUM_FEATURES; ifp->if_softc = sc; if_initname(ifp, device_get_name(sc->sc_dev), diff --git a/sys/dev/gve/gve_main.c b/sys/dev/gve/gve_main.c index cd7849778bce..f8a37b9f37a9 100644 --- a/sys/dev/gve/gve_main.c +++ b/sys/dev/gve/gve_main.c @@ -352,18 +352,13 @@ gve_get_counter(if_t ifp, ift_counter cnt) } } -static int +static void gve_setup_ifnet(device_t dev, struct gve_priv *priv) { int caps = 0; if_t ifp; ifp = priv->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(priv->dev, "Failed to allocate ifnet struct\n"); - return (ENXIO); - } - if_initname(ifp, device_get_name(dev), device_get_unit(dev)); if_setsoftc(ifp, priv); if_setdev(ifp, dev); @@ -401,8 +396,6 @@ gve_setup_ifnet(device_t dev, struct gve_priv *priv) ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO); - - return (0); } static int @@ -794,9 +787,7 @@ gve_attach(device_t dev) if (err != 0) goto abort; - err = gve_setup_ifnet(dev, priv); - if (err != 0) - goto abort; + gve_setup_ifnet(dev, priv); priv->rx_copybreak = GVE_DEFAULT_RX_COPYBREAK; diff --git a/sys/dev/iicbus/if_ic.c b/sys/dev/iicbus/if_ic.c index e87a7490e780..eea92094483a 100644 --- a/sys/dev/iicbus/if_ic.c +++ b/sys/dev/iicbus/if_ic.c @@ -164,8 +164,6 @@ icattach(device_t dev) struct ifnet *ifp; ifp = sc->ic_ifp = if_alloc(IFT_PARA); - if (ifp == NULL) - return (ENOSPC); mtx_init(&sc->ic_lock, device_get_nameunit(dev), MTX_NETWORK_LOCK, MTX_DEF); diff --git a/sys/dev/jme/if_jme.c b/sys/dev/jme/if_jme.c index 219ac675308d..5cef827d3649 100644 --- a/sys/dev/jme/if_jme.c +++ b/sys/dev/jme/if_jme.c @@ -807,12 +807,6 @@ jme_attach(device_t dev) goto fail; ifp = sc->jme_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "cannot allocate ifnet structure.\n"); - error = ENXIO; - goto fail; - } - ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; diff --git a/sys/dev/le/lance.c b/sys/dev/le/lance.c index 63a742bad366..19c1e07f854c 100644 --- a/sys/dev/le/lance.c +++ b/sys/dev/le/lance.c @@ -112,8 +112,6 @@ lance_config(struct lance_softc *sc, const char* name, int unit) return (ENXIO); ifp = sc->sc_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) - return (ENOSPC); callout_init_mtx(&sc->sc_wdog_ch, &sc->sc_mtx, 0); diff --git a/sys/dev/lge/if_lge.c b/sys/dev/lge/if_lge.c index f2924ffcd457..3805d96c94b2 100644 --- a/sys/dev/lge/if_lge.c +++ b/sys/dev/lge/if_lge.c @@ -514,11 +514,6 @@ lge_attach(device_t dev) } ifp = sc->lge_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not if_alloc()\n"); - error = ENOSPC; - goto fail; - } ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; diff --git a/sys/dev/liquidio/lio_main.c b/sys/dev/liquidio/lio_main.c index 9b990282d7f5..92a3a4fb3776 100644 --- a/sys/dev/liquidio/lio_main.c +++ b/sys/dev/liquidio/lio_main.c @@ -1331,11 +1331,6 @@ lio_setup_nic_devices(struct octeon_device *octeon_dev) ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - lio_dev_err(octeon_dev, "Device allocation failed\n"); - goto setup_nic_dev_fail; - } - lio = malloc(sizeof(struct lio), M_DEVBUF, M_NOWAIT | M_ZERO); if (lio == NULL) { diff --git a/sys/dev/mge/if_mge.c b/sys/dev/mge/if_mge.c index 987511c775de..5f31711468c5 100644 --- a/sys/dev/mge/if_mge.c +++ b/sys/dev/mge/if_mge.c @@ -849,12 +849,6 @@ mge_attach(device_t dev) /* Allocate network interface */ ifp = sc->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "if_alloc() failed\n"); - mge_detach(dev); - return (ENOMEM); - } - if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_softc = sc; ifp->if_flags = IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST; diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c b/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c index bae22317574b..d68b3e0e0c21 100644 --- a/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c +++ b/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c @@ -2143,11 +2143,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, priv = kzalloc(sizeof(*priv), GFP_KERNEL); *** 1193 LINES SKIPPED ***