git: 6b1f530935c5 - stable/14 - net: Remove unneeded NULL check for the allocated ifnet

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Fri, 12 Jul 2024 12:05:08 UTC
The branch stable/14 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=6b1f530935c5f84ec65dad87b7c20c6b7a72a6d3

commit 6b1f530935c5f84ec65dad87b7c20c6b7a72a6d3
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-06-28 10:16:29 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-07-12 12:03:37 +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
    
    (cherry picked from commit aa3860851b9f6a6002d135b1cac7736e0995eedc)
---
 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                          |  5 -----
 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/ar40xx/ar40xx_phy.c            |  8 --------
 sys/dev/etherswitch/arswitch/arswitch.c            |  6 ------
 sys/dev/etherswitch/e6000sw/e6000sw.c              |  2 --
 sys/dev/etherswitch/e6000sw/e6060sw.c              |  6 ------
 sys/dev/etherswitch/felix/felix.c                  |  3 ---
 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                          |  6 +-----
 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/mana/mana_en.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_epair.c                                 | 11 -----------
 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                                 |  5 -----
 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 ----
 109 files changed, 33 insertions(+), 608 deletions(-)

diff --git a/sys/arm/allwinner/if_emac.c b/sys/arm/allwinner/if_emac.c
index e0826cb6584a..bfd6e68ddc37 100644
--- a/sys/arm/allwinner/if_emac.c
+++ b/sys/arm/allwinner/if_emac.c
@@ -941,11 +941,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;
-	}
 	if_setsoftc(ifp, sc);
 
 	/* Setup MII */
diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c
index 223d24019cb8..8cb748cfc119 100644
--- a/sys/arm/ti/cpsw/if_cpsw.c
+++ b/sys/arm/ti/cpsw/if_cpsw.c
@@ -1025,11 +1025,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);
 	if_setsoftc(ifp, sc);
 	if_setflags(ifp, IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST);
diff --git a/sys/dev/ae/if_ae.c b/sys/dev/ae/if_ae.c
index 061f29e91e9c..97b96161dfed 100644
--- a/sys/dev/ae/if_ae.c
+++ b/sys/dev/ae/if_ae.c
@@ -327,12 +327,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;
-	}
-
 	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/age/if_age.c b/sys/dev/age/if_age.c
index c302dd6f1965..1a8b4aa6ad3f 100644
--- a/sys/dev/age/if_age.c
+++ b/sys/dev/age/if_age.c
@@ -591,12 +591,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;
-	}
-
 	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/alc/if_alc.c b/sys/dev/alc/if_alc.c
index 2943be7063b5..c83cd1bf6869 100644
--- a/sys/dev/alc/if_alc.c
+++ b/sys/dev/alc/if_alc.c
@@ -1585,12 +1585,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;
-	}
-
 	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/ale/if_ale.c b/sys/dev/ale/if_ale.c
index 510a029cd18f..e8e7a55e9b8f 100644
--- a/sys/dev/ale/if_ale.c
+++ b/sys/dev/ale/if_ale.c
@@ -610,12 +610,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;
-	}
-
 	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/altera/atse/if_atse.c b/sys/dev/altera/atse/if_atse.c
index 923292484207..9e3871cf5779 100644
--- a/sys/dev/altera/atse/if_atse.c
+++ b/sys/dev/altera/atse/if_atse.c
@@ -1372,11 +1372,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;
-	}
 	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/axgbe/if_axgbe.c b/sys/dev/axgbe/if_axgbe.c
index 4641c346bb63..9c6d7d845f2d 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 2564d0c1dac6..226fca16ac28 100644
--- a/sys/dev/bce/if_bce.c
+++ b/sys/dev/bce/if_bce.c
@@ -1351,12 +1351,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. */
 	if_setsoftc(ifp, sc);
diff --git a/sys/dev/bfe/if_bfe.c b/sys/dev/bfe/if_bfe.c
index de5c43087fa3..e488300dc944 100644
--- a/sys/dev/bfe/if_bfe.c
+++ b/sys/dev/bfe/if_bfe.c
@@ -478,11 +478,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;
-	}
 	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/bge/if_bge.c b/sys/dev/bge/if_bge.c
index 3e43b8e31442..e8af6530354f 100644
--- a/sys/dev/bge/if_bge.c
+++ b/sys/dev/bge/if_bge.c
@@ -3712,11 +3712,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 8524deeb354e..05bc22c0c981 100644
--- a/sys/dev/bxe/bxe.c
+++ b/sys/dev/bxe/bxe.c
@@ -12965,7 +12965,7 @@ bxe_init(void *xsc)
     BXE_CORE_UNLOCK(sc);
 }
 
-static int
+static void
 bxe_init_ifnet(struct bxe_softc *sc)
 {
     if_t ifp;
@@ -12985,10 +12985,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));
@@ -13034,8 +13031,6 @@ bxe_init_ifnet(struct bxe_softc *sc)
 
     /* Attach driver debugnet methods. */
     DEBUGNET_SET(ifp, bxe);
-
-    return (0);
 }
 
 static void
@@ -16261,12 +16256,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 6e4a62f6e5ee..80b35db73c46 100644
--- a/sys/dev/cadence/if_cgem.c
+++ b/sys/dev/cadence/if_cgem.c
@@ -1814,11 +1814,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 0cf17cf04b33..76d1b713e5bb 100644
--- a/sys/dev/cas/if_cas.c
+++ b/sys/dev/cas/if_cas.c
@@ -188,8 +188,6 @@ cas_attach(struct cas_softc *sc)
 
 	/* Set up ifnet structure. */
 	ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL)
-		return (ENOSPC);
 	if_setsoftc(ifp, 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 c5fc067f8312..9bcdb86312c4 100644
--- a/sys/dev/cxgb/cxgb_main.c
+++ b/sys/dev/cxgb/cxgb_main.c
@@ -1011,11 +1011,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));
 	if_setinitfn(ifp, cxgb_init);
 	if_setsoftc(ifp, p);
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 28119bd419bb..128d2ae65611 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -2549,7 +2549,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)
 {
 	if_t ifp;
@@ -2588,10 +2588,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;
 	if_setsoftc(ifp, vi);
 
@@ -2694,8 +2690,6 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
 	pa.pa_type = PFIL_TYPE_ETHERNET;
 	pa.pa_headname = if_name(ifp);
 	vi->pfil = pfil_head_register(&pa);
-
-	return (0);
 }
 
 static int
@@ -2704,13 +2698,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)
@@ -3589,11 +3581,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 d9b336c4b64a..80689a543e83 100644
--- a/sys/dev/cxgbe/t4_tracer.c
+++ b/sys/dev/cxgbe/t4_tracer.c
@@ -167,11 +167,6 @@ t4_cloner_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
 	}
 
 	ifp = if_alloc(IFT_ETHER);
-	if (ifp == NULL) {
-		rc = ENOMEM;
-		goto done;
-	}
-
 	/* Note that if_xname is identical to the nexus nameunit */
 	if_initname(ifp, name, -1);
 	if_setdname(ifp, t4_cloner_name);
diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c
index ddb81d8a486c..809feed7855f 100644
--- a/sys/dev/dc/if_dc.c
+++ b/sys/dev/dc/if_dc.c
@@ -2380,11 +2380,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;
-	}
 	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/dpaa/if_dtsec.c b/sys/dev/dpaa/if_dtsec.c
index 2c0dee05a03f..dfa76a476620 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);
-	}
-
 	if_setsoftc(ifp, sc);
 
 	if_setflags(ifp, IFF_SIMPLEX | IFF_BROADCAST);
diff --git a/sys/dev/dpaa2/dpaa2_ni.c b/sys/dev/dpaa2/dpaa2_ni.c
index a9e6aa120549..a21351a20b49 100644
--- a/sys/dev/dpaa2/dpaa2_ni.c
+++ b/sys/dev/dpaa2/dpaa2_ni.c
@@ -548,11 +548,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__);
-		goto err_exit;
-	}
 	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 3ff32cc9966c..47d066a2e4f1 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);
@@ -2516,8 +2512,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
@@ -3811,11 +3805,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);
@@ -3852,7 +3842,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 62bafd4c4113..5f5911eb2ae6 100644
--- a/sys/dev/et/if_et.c
+++ b/sys/dev/et/if_et.c
@@ -232,11 +232,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/ar40xx/ar40xx_phy.c b/sys/dev/etherswitch/ar40xx/ar40xx_phy.c
index 3e2bcd4af18d..11d9f8d47c0f 100644
--- a/sys/dev/etherswitch/ar40xx/ar40xx_phy.c
+++ b/sys/dev/etherswitch/ar40xx/ar40xx_phy.c
@@ -200,14 +200,6 @@ ar40xx_attach_phys(struct ar40xx_softc *sc)
 	snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev));
 	for (phy = 0; phy < AR40XX_NUM_PHYS; phy++) {
 		sc->sc_phys.ifp[phy] = if_alloc(IFT_ETHER);
-		if (sc->sc_phys.ifp[phy] == NULL) {
-			device_printf(sc->sc_dev,
-			    "PHY %d: couldn't allocate ifnet structure\n",
-			    phy);
-			err = ENOMEM;
-			break;
-		}
-
 		sc->sc_phys.ifp[phy]->if_softc = sc;
 		sc->sc_phys.ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST |
 		    IFF_DRV_RUNNING | IFF_SIMPLEX;
diff --git a/sys/dev/etherswitch/arswitch/arswitch.c b/sys/dev/etherswitch/arswitch/arswitch.c
index 70f3ad501d5d..f1e6d1944038 100644
--- a/sys/dev/etherswitch/arswitch/arswitch.c
+++ b/sys/dev/etherswitch/arswitch/arswitch.c
@@ -150,12 +150,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;
-		}
-
 		if_setsoftc(sc->ifp[phy], sc);
 		if_setflagbits(sc->ifp[phy], IFF_UP | IFF_BROADCAST |
 		    IFF_DRV_RUNNING | IFF_SIMPLEX, 0);
diff --git a/sys/dev/etherswitch/e6000sw/e6000sw.c b/sys/dev/etherswitch/e6000sw/e6000sw.c
index 95f1a2e96db6..3b309f7f36f8 100644
--- a/sys/dev/etherswitch/e6000sw/e6000sw.c
+++ b/sys/dev/etherswitch/e6000sw/e6000sw.c
@@ -454,8 +454,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);
 	if_setsoftc(sc->ifp[port], sc);
 	if_setflagbits(sc->ifp[port], IFF_UP | IFF_BROADCAST |
 	    IFF_DRV_RUNNING | IFF_SIMPLEX, 0);
diff --git a/sys/dev/etherswitch/e6000sw/e6060sw.c b/sys/dev/etherswitch/e6000sw/e6060sw.c
index 8bc482af24e8..3ff38abb69a0 100644
--- a/sys/dev/etherswitch/e6000sw/e6060sw.c
+++ b/sys/dev/etherswitch/e6000sw/e6060sw.c
@@ -214,12 +214,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/felix/felix.c b/sys/dev/etherswitch/felix/felix.c
index f7d79ab33e13..ecd967015d00 100644
--- a/sys/dev/etherswitch/felix/felix.c
+++ b/sys/dev/etherswitch/felix/felix.c
@@ -241,9 +241,6 @@ felix_init_interface(felix_softc_t sc, int port)
 	snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->dev));
 
 	sc->ports[port].ifp = if_alloc(IFT_ETHER);
-	if (sc->ports[port].ifp == NULL)
-		return (ENOMEM);
-
 	if_setsoftc(sc->ports[port].ifp, sc);
 	if_setflags(sc->ports[port].ifp, IFF_UP | IFF_BROADCAST | IFF_MULTICAST |
 	    IFF_DRV_RUNNING | IFF_SIMPLEX);
diff --git a/sys/dev/etherswitch/infineon/adm6996fc.c b/sys/dev/etherswitch/infineon/adm6996fc.c
index 95a24a2fb37a..2c6c83a4388d 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 45119ded83a9..5e07e1f72b80 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;
-		}
-
 		if_setsoftc(sc->ifp[port], sc);
 		if_setflags(sc->ifp[port], 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 2b5af2a5625a..e512a86202c6 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 75f7cbfa6941..fa96a81b40ef 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 8a74ae189284..761a96b0ec80 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;
-		}
-
 		if_setsoftc(sc->ifp[i], sc);
 		if_setflagbits(sc->ifp[i], IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING
 			| IFF_SIMPLEX, 0);
diff --git a/sys/dev/etherswitch/ukswitch/ukswitch.c b/sys/dev/etherswitch/ukswitch/ukswitch.c
index c1e23f7c0f65..f2cf6ef74e90 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;
-		}
-
 		if_setsoftc(sc->ifp[port], sc);
 		if_setflags(sc->ifp[port], 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 60a9806656e8..44d3425799e9 100644
--- a/sys/dev/firewire/if_fwe.c
+++ b/sys/dev/firewire/if_fwe.c
@@ -178,10 +178,6 @@ 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);
-	}
 	if_setsoftc(ifp, &fwe->eth_softc);
 
 	if_initname(ifp, device_get_name(dev), unit);
@@ -201,7 +197,7 @@ fwe_attach(device_t dev)
 	if_setcapenablebit(ifp, IFCAP_VLAN_MTU, 0);
 
 	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 5237c555d999..91a27800f308 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 8d695861cffc..966647051c21 100644
--- a/sys/dev/fxp/if_fxp.c
+++ b/sys/dev/fxp/if_fxp.c
@@ -443,11 +443,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 91389d0dfd2c..434c5309d019 100644
--- a/sys/dev/gem/if_gem.c
+++ b/sys/dev/gem/if_gem.c
@@ -152,8 +152,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;
 	if_setsoftc(ifp, 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 52ab5afb9c4e..caca35a3d22b 100644
--- a/sys/dev/iicbus/if_ic.c
+++ b/sys/dev/iicbus/if_ic.c
@@ -162,8 +162,6 @@ icattach(device_t dev)
 	if_t 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 89c78d80afe0..3631e5f8ffa0 100644
--- a/sys/dev/jme/if_jme.c
+++ b/sys/dev/jme/if_jme.c
@@ -805,12 +805,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;
-	}
-
 	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/le/lance.c b/sys/dev/le/lance.c
index e09e82eb34cc..6add3aa4a1b5 100644
--- a/sys/dev/le/lance.c
+++ b/sys/dev/le/lance.c
@@ -110,8 +110,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 d77866ee3cad..dfcaa01d366b 100644
--- a/sys/dev/lge/if_lge.c
+++ b/sys/dev/lge/if_lge.c
@@ -512,11 +512,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;
-	}
 	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/liquidio/lio_main.c b/sys/dev/liquidio/lio_main.c
index aa52612dda04..7104ff07674f 100644
--- a/sys/dev/liquidio/lio_main.c
+++ b/sys/dev/liquidio/lio_main.c
@@ -1327,11 +1327,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;
*** 1276 LINES SKIPPED ***