diff --git a/sys/arm/allwinner/if_emac.c b/sys/arm/allwinner/if_emac.c index e0826cb6584..bfd6e68ddc3 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 223d24019cb..8cb748cfc11 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 061f29e91e9..97b96161dfe 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 c302dd6f196..1a8b4aa6ad3 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 2943be7063b..c83cd1bf686 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 510a029cd18..e8e7a55e9b8 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 92329248420..9e3871cf577 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 4641c346bb6..9c6d7d845f2 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 2564d0c1dac..226fca16ac2 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 de5c43087fa..e488300dc94 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 3e43b8e3144..e8af6530354 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 8524deeb354..05bc22c0c98 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 6e4a62f6e5e..80b35db73c4 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 0cf17cf04b3..76d1b713e5b 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 c5fc067f831..9bcdb86312c 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 28119bd419b..128d2ae6561 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 d9b336c4b64..80689a543e8 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 ddb81d8a486..809feed7855 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 2c0dee05a03..dfa76a47662 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 a9e6aa12054..a21351a20b4 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 3ff32cc9966..47d066a2e4f 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 62bafd4c411..5f5911eb2ae 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 3e2bcd4af18..11d9f8d47c0 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 70f3ad501d5..f1e6d194403 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 95f1a2e96db..3b309f7f36f 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 8bc482af24e..3ff38abb69a 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 f7d79ab33e1..ecd967015d0 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 95a24a2fb37..2c6c83a4388 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 45119ded83a..5e07e1f72b8 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 2b5af2a5625..e512a86202c 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 75f7cbfa694..fa96a81b40e 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 8a74ae18928..761a96b0ec8 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 c1e23f7c0f6..f2cf6ef74e9 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 60a9806656e..44d3425799e 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 5237c555d99..91a27800f30 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 8d695861cff..966647051c2 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 91389d0dfd2..434c5309d01 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 cd7849778bc..f8a37b9f37a 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 52ab5afb9c4..caca35a3d22 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 89c78d80afe..3631e5f8ffa 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 e09e82eb34c..6add3aa4a1b 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 d77866ee3ca..dfcaa01d366 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 aa52612dda0..7104ff07674 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; - } - lio = malloc(sizeof(struct lio), M_DEVBUF, M_NOWAIT | M_ZERO); if (lio == NULL) { diff --git a/sys/dev/mana/mana_en.c b/sys/dev/mana/mana_en.c index 09de49a1101..50a6192e5fb 100644 --- a/sys/dev/mana/mana_en.c +++ b/sys/dev/mana/mana_en.c @@ -2805,11 +2805,6 @@ mana_probe_port(struct mana_context *ac, int port_idx, int err; ndev = if_alloc_dev(IFT_ETHER, gc->dev); - if (!ndev) { - mana_err(NULL, "Failed to allocate ifnet struct\n"); - return ENOMEM; - } - *ndev_storage = ndev; apc = malloc(sizeof(*apc), M_DEVBUF, M_WAITOK | M_ZERO); diff --git a/sys/dev/mge/if_mge.c b/sys/dev/mge/if_mge.c index 30650cc6df8..02b182eda41 100644 --- a/sys/dev/mge/if_mge.c +++ b/sys/dev/mge/if_mge.c @@ -848,12 +848,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)); if_setsoftc(ifp, sc); if_setflags(ifp, 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 583de1816d1..ac4bfd1b1a1 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); dev = priv->dev = if_alloc(IFT_ETHER); - if (dev == NULL) { - en_err(priv, "Net device allocation failed\n"); - kfree(priv); - return -ENOMEM; - } if_setsoftc(dev, priv); if_initname(dev, "mlxen", (device_get_unit( mdev->pdev->dev.bsddev) * MLX4_MAX_PORTS) + port - 1); diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c index 962705e6d25..97ec1b4420a 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c @@ -4488,10 +4488,6 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev) M_MLX5EN, mlx5_dev_domainset(mdev), M_WAITOK | M_ZERO); ifp = priv->ifp = if_alloc_dev(IFT_ETHER, mdev->pdev->dev.bsddev); - if (ifp == NULL) { - mlx5_core_err(mdev, "if_alloc() failed\n"); - goto err_free_priv; - } /* setup all static fields */ if (mlx5e_priv_static_init(priv, mdev, mdev->priv.eq_table.num_comp_vectors)) { mlx5_core_err(mdev, "mlx5e_priv_static_init() failed\n"); @@ -4831,8 +4827,6 @@ err_free_sysctl: err_free_ifp: if_free(ifp); - -err_free_priv: free(priv, M_MLX5EN); return (NULL); } diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index ea6157cbbec..ff9fdb96b74 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -1624,11 +1624,6 @@ msk_attach(device_t dev) msk_rx_dma_jalloc(sc_if); ifp = sc_if->msk_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(sc_if->msk_if_dev, "can not if_alloc()\n"); - error = ENOSPC; - goto fail; - } if_setsoftc(ifp, sc_if); 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/mxge/if_mxge.c b/sys/dev/mxge/if_mxge.c index 26d6410f356..158bb8e5888 100644 --- a/sys/dev/mxge/if_mxge.c +++ b/sys/dev/mxge/if_mxge.c @@ -4641,11 +4641,6 @@ mxge_attach(device_t dev) } ifp = sc->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not if_alloc()\n"); - err = ENOSPC; - goto abort_with_parent_dmat; - } if_initname(ifp, device_get_name(dev), device_get_unit(dev)); snprintf(sc->cmd_mtx_name, sizeof(sc->cmd_mtx_name), "%s:cmd", @@ -4814,7 +4809,6 @@ abort_with_lock: mtx_destroy(&sc->cmd_mtx); mtx_destroy(&sc->driver_mtx); if_free(ifp); -abort_with_parent_dmat: bus_dma_tag_destroy(sc->parent_dmat); abort_with_tq: if (sc->tq != NULL) { diff --git a/sys/dev/my/if_my.c b/sys/dev/my/if_my.c index 2bf4573d337..3de394f424a 100644 --- a/sys/dev/my/if_my.c +++ b/sys/dev/my/if_my.c @@ -874,11 +874,6 @@ my_attach(device_t dev) bzero(sc->my_ldata, sizeof(struct my_list_data)); ifp = sc->my_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not if_alloc()\n"); - error = ENOSPC; - goto free_ldata; - } if_setsoftc(ifp, sc); if_initname(ifp, device_get_name(dev), device_get_unit(dev)); if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); @@ -962,7 +957,6 @@ detach_if: ether_ifdetach(ifp); free_if: if_free(ifp); -free_ldata: free(sc->my_ldata_ptr, M_DEVBUF); release_irq: bus_release_resource(dev, SYS_RES_IRQ, 0, sc->my_irq); diff --git a/sys/dev/neta/if_mvneta.c b/sys/dev/neta/if_mvneta.c index bb95bc9c588..fdd6467edde 100644 --- a/sys/dev/neta/if_mvneta.c +++ b/sys/dev/neta/if_mvneta.c @@ -612,11 +612,6 @@ mvneta_attach(device_t self) /* Allocate network interface */ ifp = sc->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(self, "if_alloc() failed\n"); - mvneta_detach(self); - return (ENOMEM); - } if_initname(ifp, device_get_name(self), device_get_unit(self)); /* diff --git a/sys/dev/netmap/if_ptnet.c b/sys/dev/netmap/if_ptnet.c index 56d853eb739..cea62517b2e 100644 --- a/sys/dev/netmap/if_ptnet.c +++ b/sys/dev/netmap/if_ptnet.c @@ -399,12 +399,6 @@ ptnet_attach(device_t dev) /* Setup Ethernet interface. */ sc->ifp = ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "Failed to allocate ifnet\n"); - err = ENOMEM; - goto err_path; - } - if_initname(ifp, device_get_name(dev), device_get_unit(dev)); if_setbaudrate(ifp, IF_Gbps(10)); if_setsoftc(ifp, sc); diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c index cf3578ddc7f..215b1f7bd09 100644 --- a/sys/dev/netmap/netmap_freebsd.c +++ b/sys/dev/netmap/netmap_freebsd.c @@ -612,10 +612,6 @@ nm_os_vi_persist(const char *name, if_t *ret) eaddr[5] = (uint8_t)unit; ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - nm_prerr("if_alloc failed"); - return ENOMEM; - } if_initname(ifp, name, IF_DUNIT_NONE); if_setflags(ifp, IFF_UP | IFF_SIMPLEX | IFF_MULTICAST); if_setinitfn(ifp, (void *)nm_vi_dummy); diff --git a/sys/dev/nfe/if_nfe.c b/sys/dev/nfe/if_nfe.c index aedae79ddf8..15f4cd1f7c7 100644 --- a/sys/dev/nfe/if_nfe.c +++ b/sys/dev/nfe/if_nfe.c @@ -567,11 +567,6 @@ nfe_attach(device_t dev) goto fail; ifp = sc->nfe_ifp = if_gethandle(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not if_gethandle()\n"); - error = ENOSPC; - goto fail; - } /* * Allocate Tx and Rx rings. diff --git a/sys/dev/nge/if_nge.c b/sys/dev/nge/if_nge.c index dc3be913f89..c7c2b3c99d5 100644 --- a/sys/dev/nge/if_nge.c +++ b/sys/dev/nge/if_nge.c @@ -900,11 +900,6 @@ nge_attach(device_t dev) nge_sysctl_node(sc); ifp = sc->nge_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not allocate ifnet structure\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/ntb/if_ntb/if_ntb.c b/sys/dev/ntb/if_ntb/if_ntb.c index fb0c601f422..59a2e76ee14 100644 --- a/sys/dev/ntb/if_ntb/if_ntb.c +++ b/sys/dev/ntb/if_ntb/if_ntb.c @@ -137,10 +137,6 @@ ntb_net_attach(device_t dev) int i; ifp = sc->ifp = if_gethandle(IFT_ETHER); - if (ifp == NULL) { - printf("ntb: Cannot allocate ifnet structure\n"); - return (ENOMEM); - } if_initname(ifp, device_get_name(dev), device_get_unit(dev)); if_setdev(ifp, dev); diff --git a/sys/dev/oce/oce_if.c b/sys/dev/oce/oce_if.c index 2084b9c84ff..bf257b952a0 100644 --- a/sys/dev/oce/oce_if.c +++ b/sys/dev/oce/oce_if.c @@ -170,7 +170,7 @@ static void oce_rx_lro(struct oce_rq *rq, struct nic_hwlro_singleton_cqe *cqe, s static void oce_rx_mbuf_chain(struct oce_rq *rq, struct oce_common_cqe_info *cqe_info, struct mbuf **m); /* Helper function prototypes in this file */ -static int oce_attach_ifp(POCE_SOFTC sc); +static void oce_attach_ifp(POCE_SOFTC sc); static void oce_add_vlan(void *arg, if_t ifp, uint16_t vtag); static void oce_del_vlan(void *arg, if_t ifp, uint16_t vtag); static int oce_vid_config(POCE_SOFTC sc); @@ -334,9 +334,7 @@ oce_attach(device_t dev) if (rc) goto intr_free; - rc = oce_attach_ifp(sc); - if (rc) - goto queues_free; + oce_attach_ifp(sc); #if defined(INET6) || defined(INET) rc = oce_init_lro(sc); @@ -392,7 +390,6 @@ ifp_free: #endif ether_ifdetach(sc->ifp); if_free(sc->ifp); -queues_free: oce_queue_release_all(sc); intr_free: oce_intr_free(sc); @@ -2099,13 +2096,11 @@ oce_rq_handler(void *arg) * Helper function prototypes in this file * *****************************************************************************/ -static int +static void oce_attach_ifp(POCE_SOFTC sc) { sc->ifp = if_alloc(IFT_ETHER); - if (!sc->ifp) - return ENOMEM; ifmedia_init(&sc->media, IFM_IMASK, oce_media_change, oce_media_status); ifmedia_add(&sc->media, IFM_ETHER | IFM_AUTO, 0, NULL); @@ -2148,8 +2143,6 @@ oce_attach_ifp(POCE_SOFTC sc) if_sethwtsomaxsegsize(sc->ifp, 4096); ether_ifattach(sc->ifp, sc->macaddr.mac_addr); - - return 0; } static void diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c index a9ef8dc016b..c2adcb602f6 100644 --- a/sys/dev/ppbus/if_plip.c +++ b/sys/dev/ppbus/if_plip.c @@ -249,10 +249,6 @@ lp_attach(device_t dev) } ifp = lp->sc_ifp = if_alloc(IFT_PARA); - if (ifp == NULL) { - return (ENOSPC); - } - if_setsoftc(ifp, lp); if_initname(ifp, device_get_name(dev), device_get_unit(dev)); if_setmtu(ifp, LPMTU); diff --git a/sys/dev/qlnx/qlnxe/qlnx_os.c b/sys/dev/qlnx/qlnxe/qlnx_os.c index 21d39e809cc..6665894d058 100644 --- a/sys/dev/qlnx/qlnxe/qlnx_os.c +++ b/sys/dev/qlnx/qlnxe/qlnx_os.c @@ -2292,10 +2292,6 @@ qlnx_init_ifnet(device_t dev, qlnx_host_t *ha) if_t ifp; ifp = ha->ifp = if_alloc(IFT_ETHER); - - if (ifp == NULL) - panic("%s: cannot if_alloc()\n", device_get_nameunit(dev)); - if_initname(ifp, device_get_name(dev), device_get_unit(dev)); device_id = pci_get_device(ha->pci_dev); diff --git a/sys/dev/qlxgb/qla_os.c b/sys/dev/qlxgb/qla_os.c index b9a0c1ec07a..87e504a83c7 100644 --- a/sys/dev/qlxgb/qla_os.c +++ b/sys/dev/qlxgb/qla_os.c @@ -658,9 +658,6 @@ qla_init_ifnet(device_t dev, qla_host_t *ha) ifp = ha->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) - panic("%s: cannot if_alloc()\n", device_get_nameunit(dev)); - if_initname(ifp, device_get_name(dev), device_get_unit(dev)); if_setmtu(ifp, ETHERMTU); diff --git a/sys/dev/qlxgbe/ql_os.c b/sys/dev/qlxgbe/ql_os.c index 0b3b2ca7954..a12f1efec08 100644 --- a/sys/dev/qlxgbe/ql_os.c +++ b/sys/dev/qlxgbe/ql_os.c @@ -852,10 +852,6 @@ qla_init_ifnet(device_t dev, qla_host_t *ha) QL_DPRINT2(ha, (dev, "%s: enter\n", __func__)); ifp = ha->ifp = if_alloc(IFT_ETHER); - - if (ifp == NULL) - panic("%s: cannot if_alloc()\n", device_get_nameunit(dev)); - if_initname(ifp, device_get_name(dev), device_get_unit(dev)); if_setbaudrate(ifp, IF_Gbps(10)); diff --git a/sys/dev/qlxge/qls_os.c b/sys/dev/qlxge/qls_os.c index a1ce1c637e1..eca7006850e 100644 --- a/sys/dev/qlxge/qls_os.c +++ b/sys/dev/qlxge/qls_os.c @@ -719,10 +719,6 @@ qls_init_ifnet(device_t dev, qla_host_t *ha) QL_DPRINT2((dev, "%s: enter\n", __func__)); ifp = ha->ifp = if_alloc(IFT_ETHER); - - if (ifp == NULL) - panic("%s: cannot if_alloc()\n", device_get_nameunit(dev)); - if_initname(ifp, device_get_name(dev), device_get_unit(dev)); if_setbaudrate(ifp, IF_Gbps(10)); if_setinitfn(ifp, qls_init); diff --git a/sys/dev/re/if_re.c b/sys/dev/re/if_re.c index 594ed9d6037..69593e68d36 100644 --- a/sys/dev/re/if_re.c +++ b/sys/dev/re/if_re.c @@ -1606,11 +1606,6 @@ re_attach(device_t dev) re_add_sysctls(sc); ifp = sc->rl_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not if_alloc()\n"); - error = ENOSPC; - goto fail; - } /* Take controller out of deep sleep mode. */ if ((sc->rl_flags & RL_FLAG_MACSLEEP) != 0) { diff --git a/sys/dev/rl/if_rl.c b/sys/dev/rl/if_rl.c index b8c21c3265d..cd60561ad2d 100644 --- a/sys/dev/rl/if_rl.c +++ b/sys/dev/rl/if_rl.c @@ -780,11 +780,6 @@ rl_attach(device_t dev) goto fail; ifp = sc->rl_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not if_alloc()\n"); - error = ENOSPC; - goto fail; - } #define RL_PHYAD_INTERNAL 0 diff --git a/sys/dev/sbni/if_sbni.c b/sys/dev/sbni/if_sbni.c index 4dbfae7777e..ffbce54a56f 100644 --- a/sys/dev/sbni/if_sbni.c +++ b/sys/dev/sbni/if_sbni.c @@ -212,7 +212,7 @@ sbni_probe(struct sbni_softc *sc) /* * Install interface into kernel networking data structures */ -int +void sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags) { if_t ifp; @@ -220,8 +220,6 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags) uint64_t baudrate; ifp = sc->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) - return (ENOMEM); sbni_outb(sc, CSR0, 0); set_initial_values(sc, flags); @@ -250,7 +248,6 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags) printf("auto\n"); else printf("%d (fixed)\n", sc->cur_rxl_index); - return (0); } void diff --git a/sys/dev/sbni/if_sbni_isa.c b/sys/dev/sbni/if_sbni_isa.c index 53f8c33e1bb..e1f05db634e 100644 --- a/sys/dev/sbni/if_sbni_isa.c +++ b/sys/dev/sbni/if_sbni_isa.c @@ -137,12 +137,7 @@ sbni_attach_isa(device_t dev) *(u_int32_t*)&flags = device_get_flags(dev); - error = sbni_attach(sc, device_get_unit(dev) * 2, flags); - if (error) { - device_printf(dev, "cannot initialize driver\n"); - sbni_release_resources(sc); - return (error); - } + sbni_attach(sc, device_get_unit(dev) * 2, flags); if (sc->irq_res) { error = bus_setup_intr( diff --git a/sys/dev/sbni/if_sbni_pci.c b/sys/dev/sbni/if_sbni_pci.c index 387995b1a46..06f741c6cc3 100644 --- a/sys/dev/sbni/if_sbni_pci.c +++ b/sys/dev/sbni/if_sbni_pci.c @@ -132,20 +132,9 @@ sbni_pci_attach(device_t dev) memset(&flags, 0, sizeof(flags)); - error = sbni_attach(sc, device_get_unit(dev) * 2, flags); - if (error) { - device_printf(dev, "cannot initialize driver\n"); - goto attach_failed; - } - if (sc->slave_sc) { - error = sbni_attach(sc->slave_sc, device_get_unit(dev) * 2 + 1, - flags); - if (error) { - device_printf(dev, "cannot initialize slave\n"); - sbni_detach(sc); - goto attach_failed; - } - } + sbni_attach(sc, device_get_unit(dev) * 2, flags); + if (sc->slave_sc) + sbni_attach(sc->slave_sc, device_get_unit(dev) * 2 + 1, flags); if (sc->irq_res) { error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | diff --git a/sys/dev/sbni/if_sbnivar.h b/sys/dev/sbni/if_sbnivar.h index 92678899a5d..211d2bc56b0 100644 --- a/sys/dev/sbni/if_sbnivar.h +++ b/sys/dev/sbni/if_sbnivar.h @@ -125,7 +125,7 @@ struct sbni_softc { void sbni_intr(void *); int sbni_probe(struct sbni_softc *); -int sbni_attach(struct sbni_softc *, int, struct sbni_flags); +void sbni_attach(struct sbni_softc *, int, struct sbni_flags); void sbni_detach(struct sbni_softc *); void sbni_release_resources(struct sbni_softc *); diff --git a/sys/dev/sfxge/sfxge.c b/sys/dev/sfxge/sfxge.c index 23294f90f51..5fb3a3e74c2 100644 --- a/sys/dev/sfxge/sfxge.c +++ b/sys/dev/sfxge/sfxge.c @@ -1081,11 +1081,6 @@ sfxge_attach(device_t dev) /* Allocate ifnet. */ ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "Couldn't allocate ifnet\n"); - error = ENOMEM; - goto fail; - } sc->ifnet = ifp; /* Initialize hardware. */ @@ -1122,8 +1117,6 @@ fail3: fail2: if_free(sc->ifnet); - -fail: DBGPRINT(sc->dev, "failed %d", error); return (error); } diff --git a/sys/dev/sge/if_sge.c b/sys/dev/sge/if_sge.c index 8146e7cf2e1..c6e8f479019 100644 --- a/sys/dev/sge/if_sge.c +++ b/sys/dev/sge/if_sge.c @@ -603,11 +603,6 @@ sge_attach(device_t dev) goto fail; ifp = sc->sge_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "cannot allocate ifnet structure.\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/sis/if_sis.c b/sys/dev/sis/if_sis.c index bf96383e9a4..64a43b2bf51 100644 --- a/sys/dev/sis/if_sis.c +++ b/sys/dev/sis/if_sis.c @@ -1057,11 +1057,6 @@ sis_attach(device_t dev) goto fail; ifp = sc->sis_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/sk/if_sk.c b/sys/dev/sk/if_sk.c index 7505ef58cfe..db558804738 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -1279,11 +1279,6 @@ sk_attach(device_t dev) sk_dma_jumbo_alloc(sc_if); ifp = sc_if->sk_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(sc_if->sk_if_dev, "can not if_alloc()\n"); - error = ENOSPC; - goto fail; - } if_setsoftc(ifp, sc_if); 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/smc/if_smc.c b/sys/dev/smc/if_smc.c index cc7a7b1bb12..12e903d1af9 100644 --- a/sys/dev/smc/if_smc.c +++ b/sys/dev/smc/if_smc.c @@ -313,10 +313,6 @@ smc_attach(device_t dev) sc->smc_dev = dev; ifp = sc->smc_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - error = ENOSPC; - goto done; - } mtx_init(&sc->smc_mtx, device_get_nameunit(dev), NULL, MTX_DEF); diff --git a/sys/dev/ste/if_ste.c b/sys/dev/ste/if_ste.c index 7c7eb02ccfb..06e25175c61 100644 --- a/sys/dev/ste/if_ste.c +++ b/sys/dev/ste/if_ste.c @@ -987,11 +987,6 @@ ste_attach(device_t dev) goto fail; ifp = sc->ste_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not if_alloc()\n"); - error = ENOSPC; - goto fail; - } /* Do MII setup. */ phy = MII_PHY_ANY; diff --git a/sys/dev/stge/if_stge.c b/sys/dev/stge/if_stge.c index 170d9e4da94..97c2b751d47 100644 --- a/sys/dev/stge/if_stge.c +++ b/sys/dev/stge/if_stge.c @@ -560,12 +560,6 @@ stge_attach(device_t dev) } ifp = sc->sc_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(sc->sc_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/sume/if_sume.c b/sys/dev/sume/if_sume.c index c478e2343a9..4113af5a48b 100644 --- a/sys/dev/sume/if_sume.c +++ b/sys/dev/sume/if_sume.c @@ -1144,7 +1144,7 @@ check_tx_queues(struct sume_adapter *adapter) } } -static int +static void sume_ifp_alloc(struct sume_adapter *adapter, uint32_t port) { if_t ifp; @@ -1152,11 +1152,6 @@ sume_ifp_alloc(struct sume_adapter *adapter, uint32_t port) M_ZERO | M_WAITOK); ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(adapter->dev, "cannot allocate ifnet\n"); - return (ENOMEM); - } - adapter->ifp[port] = ifp; if_setsoftc(ifp, nf_priv); @@ -1182,8 +1177,6 @@ sume_ifp_alloc(struct sume_adapter *adapter, uint32_t port) ifmedia_set(&nf_priv->media, IFM_ETHER | IFM_10G_SR); if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0); - - return (0); } static void @@ -1453,11 +1446,8 @@ sume_attach(device_t dev) goto error; /* Now do the network interfaces. */ - for (i = 0; i < SUME_NPORTS; i++) { - error = sume_ifp_alloc(adapter, i); - if (error != 0) - goto error; - } + for (i = 0; i < SUME_NPORTS; i++) + sume_ifp_alloc(adapter, i); /* Register stats and register sysctls. */ sume_sysctl_init(adapter); diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c index 6f88862d800..14f7d353303 100644 --- a/sys/dev/ti/if_ti.c +++ b/sys/dev/ti/if_ti.c @@ -2384,11 +2384,6 @@ ti_attach(device_t dev) callout_init_mtx(&sc->ti_watchdog, &sc->ti_mtx, 0); ifmedia_init(&sc->ifmedia, IFM_IMASK, ti_ifmedia_upd, ti_ifmedia_sts); ifp = sc->ti_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not if_alloc()\n"); - error = ENOSPC; - goto fail; - } if_sethwassist(ifp, TI_CSUM_FEATURES); if_setcapabilities(ifp, IFCAP_TXCSUM | IFCAP_RXCSUM); if_setcapenable(ifp, if_getcapabilities(sc->ti_ifp)); diff --git a/sys/dev/tsec/if_tsec.c b/sys/dev/tsec/if_tsec.c index 1c03110e188..80e42116ed9 100644 --- a/sys/dev/tsec/if_tsec.c +++ b/sys/dev/tsec/if_tsec.c @@ -239,12 +239,6 @@ tsec_attach(struct tsec_softc *sc) /* Create network interface for upper layers */ ifp = sc->tsec_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(sc->dev, "if_alloc() failed\n"); - tsec_detach(sc); - return (ENOMEM); - } - if_setsoftc(ifp, sc); if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev)); if_setflags(ifp, IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST); diff --git a/sys/dev/usb/net/if_usie.c b/sys/dev/usb/net/if_usie.c index aaab89a23e9..aff8ec86d8f 100644 --- a/sys/dev/usb/net/if_usie.c +++ b/sys/dev/usb/net/if_usie.c @@ -431,11 +431,6 @@ usie_attach(device_t self) /* setup ifnet (Direct IP) */ sc->sc_ifp = ifp = if_alloc(IFT_OTHER); - - if (ifp == NULL) { - device_printf(self, "Could not allocate a network interface\n"); - goto detach; - } if_initname(ifp, "usie", device_get_unit(self)); if_setsoftc(ifp, sc); diff --git a/sys/dev/usb/net/uhso.c b/sys/dev/usb/net/uhso.c index 14826734f6a..9513dbeae02 100644 --- a/sys/dev/usb/net/uhso.c +++ b/sys/dev/usb/net/uhso.c @@ -1566,10 +1566,6 @@ uhso_attach_ifnet(struct uhso_softc *sc, struct usb_interface *iface, int type) } sc->sc_ifp = ifp = if_alloc(IFT_OTHER); - if (sc->sc_ifp == NULL) { - device_printf(sc->sc_dev, "if_alloc() failed\n"); - return (-1); - } callout_init_mtx(&sc->sc_c, &sc->sc_mtx, 0); mtx_lock(&sc->sc_mtx); diff --git a/sys/dev/usb/net/usb_ethernet.c b/sys/dev/usb/net/usb_ethernet.c index 2b90c924985..1efd82ccda1 100644 --- a/sys/dev/usb/net/usb_ethernet.c +++ b/sys/dev/usb/net/usb_ethernet.c @@ -221,11 +221,6 @@ ue_attach_post_task(struct usb_proc_msg *_task) error = 0; CURVNET_SET_QUIET(vnet0); ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(ue->ue_dev, "could not allocate ifnet\n"); - goto fail; - } - if_setsoftc(ifp, ue); if_initname(ifp, "ue", ue->ue_unit); if (ue->ue_methods->ue_attach_post_sub != NULL) { diff --git a/sys/dev/usb/usb_pf.c b/sys/dev/usb/usb_pf.c index 43e81968485..3b03e80db48 100644 --- a/sys/dev/usb/usb_pf.c +++ b/sys/dev/usb/usb_pf.c @@ -195,12 +195,6 @@ usbpf_clone_create(struct if_clone *ifc, char *name, size_t len, return (error); } ifp = ubus->ifp = if_alloc(IFT_USB); - if (ifp == NULL) { - ifc_free_unit(ifc, unit); - device_printf(ubus->parent, "usbpf: Could not allocate " - "instance\n"); - return (ENOSPC); - } if_setsoftc(ifp, ubus); if_initname(ifp, usbusname, unit); if_setname(ifp, name); diff --git a/sys/dev/vge/if_vge.c b/sys/dev/vge/if_vge.c index 37606f28ba1..9f71049a150 100644 --- a/sys/dev/vge/if_vge.c +++ b/sys/dev/vge/if_vge.c @@ -1093,12 +1093,6 @@ vge_attach(device_t dev) goto fail; ifp = sc->vge_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not if_alloc()\n"); - error = ENOSPC; - goto fail; - } - vge_miipoll_start(sc); /* Do MII setup */ error = mii_attach(dev, &sc->vge_miibus, ifp, vge_ifmedia_upd, diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index 245a6b6d735..0292458bfc4 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -116,7 +116,7 @@ static void vtnet_free_rxtx_queues(struct vtnet_softc *); static int vtnet_alloc_rx_filters(struct vtnet_softc *); static void vtnet_free_rx_filters(struct vtnet_softc *); static int vtnet_alloc_virtqueues(struct vtnet_softc *); -static int vtnet_alloc_interface(struct vtnet_softc *); +static void vtnet_alloc_interface(struct vtnet_softc *); static int vtnet_setup_interface(struct vtnet_softc *); static int vtnet_ioctl_mtu(struct vtnet_softc *, u_int); static int vtnet_ioctl_ifflags(struct vtnet_softc *); @@ -438,12 +438,7 @@ vtnet_attach(device_t dev) callout_init_mtx(&sc->vtnet_tick_ch, VTNET_CORE_MTX(sc), 0); vtnet_load_tunables(sc); - error = vtnet_alloc_interface(sc); - if (error) { - device_printf(dev, "cannot allocate interface\n"); - goto fail; - } - + vtnet_alloc_interface(sc); vtnet_setup_sysctl(sc); error = vtnet_setup_features(sc); @@ -1078,7 +1073,7 @@ vtnet_alloc_virtqueues(struct vtnet_softc *sc) return (error); } -static int +static void vtnet_alloc_interface(struct vtnet_softc *sc) { device_t dev; @@ -1087,14 +1082,9 @@ vtnet_alloc_interface(struct vtnet_softc *sc) dev = sc->vtnet_dev; ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) - return (ENOMEM); - sc->vtnet_ifp = ifp; if_setsoftc(ifp, sc); if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - - return (0); } static int diff --git a/sys/dev/vnic/nicvf_main.c b/sys/dev/vnic/nicvf_main.c index f5cf99ef0ce..dd44e420c78 100644 --- a/sys/dev/vnic/nicvf_main.c +++ b/sys/dev/vnic/nicvf_main.c @@ -139,7 +139,7 @@ static void nicvf_config_cpi(struct nicvf *); static int nicvf_rss_init(struct nicvf *); static int nicvf_init_resources(struct nicvf *); -static int nicvf_setup_ifnet(struct nicvf *); +static void nicvf_setup_ifnet(struct nicvf *); static int nicvf_setup_ifmedia(struct nicvf *); static void nicvf_hw_addr_random(uint8_t *); @@ -247,11 +247,7 @@ nicvf_attach(device_t dev) nicvf_rss_init(nic); NICVF_CORE_UNLOCK(nic); - err = nicvf_setup_ifnet(nic); - if (err != 0) { - device_printf(dev, "Could not set-up ifnet\n"); - goto err_release_intr; - } + nicvf_setup_ifnet(nic); err = nicvf_setup_ifmedia(nic); if (err != 0) { @@ -329,17 +325,12 @@ nicvf_hw_addr_random(uint8_t *hwaddr) memcpy(hwaddr, addr, ETHER_ADDR_LEN); } -static int +static void nicvf_setup_ifnet(struct nicvf *nic) { if_t ifp; ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(nic->dev, "Could not allocate ifnet structure\n"); - return (ENOMEM); - } - nic->ifp = ifp; if_setsoftc(ifp, nic); @@ -379,8 +370,6 @@ nicvf_setup_ifnet(struct nicvf *nic) if (nic->hw_tso) if_sethwassistbits(ifp, (CSUM_TSO), 0); if_setcapenable(ifp, if_getcapabilities(ifp)); - - return (0); } static int diff --git a/sys/dev/vnic/thunder_mdio.c b/sys/dev/vnic/thunder_mdio.c index 9fc97672b5a..38d989e7f2d 100644 --- a/sys/dev/vnic/thunder_mdio.c +++ b/sys/dev/vnic/thunder_mdio.c @@ -454,10 +454,6 @@ thunder_mdio_phy_connect(device_t dev, int lmacid, int phy) if (pd == NULL) return (ENOMEM); pd->ifp = if_alloc(IFT_ETHER); - if (pd->ifp == NULL) { - free(pd, M_THUNDER_MDIO); - return (ENOMEM); - } pd->lmacid = lmacid; } diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c index 2afe16e3c6d..02b55ef4f30 100644 --- a/sys/dev/vr/if_vr.c +++ b/sys/dev/vr/if_vr.c @@ -656,11 +656,6 @@ vr_attach(device_t dev) /* Allocate ifnet structure. */ ifp = sc->vr_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "couldn't allocate ifnet structure\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/vte/if_vte.c b/sys/dev/vte/if_vte.c index ca2fda43bc7..0cddb4fce91 100644 --- a/sys/dev/vte/if_vte.c +++ b/sys/dev/vte/if_vte.c @@ -436,12 +436,6 @@ vte_attach(device_t dev) vte_get_macaddr(sc); ifp = sc->vte_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/xilinx/if_xae.c b/sys/dev/xilinx/if_xae.c index b2447a3d031..1e94f1048ed 100644 --- a/sys/dev/xilinx/if_xae.c +++ b/sys/dev/xilinx/if_xae.c @@ -991,11 +991,6 @@ xae_attach(device_t dev) /* Set up the ethernet interface. */ sc->ifp = ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "could not allocate ifp.\n"); - return (ENXIO); - } - 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/xl/if_xl.c b/sys/dev/xl/if_xl.c index 573bc658157..32f95549b77 100644 --- a/sys/dev/xl/if_xl.c +++ b/sys/dev/xl/if_xl.c @@ -1188,11 +1188,6 @@ xl_attach(device_t dev) /* Initialize interface name. */ ifp = sc->xl_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)); diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 1e6f9b578ee..723b92d3dcd 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -754,10 +754,6 @@ bridge_clone_create(struct if_clone *ifc, char *name, size_t len, sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO); ifp = sc->sc_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - free(sc, M_DEVBUF); - return (ENOSPC); - } BRIDGE_LOCK_INIT(sc); sc->sc_brtmax = BRIDGE_RTABLE_MAX; diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c index 193bb31d138..93ce10b8f85 100644 --- a/sys/net/if_disc.c +++ b/sys/net/if_disc.c @@ -87,11 +87,6 @@ disc_clone_create(struct if_clone *ifc, int unit, caddr_t params) sc = malloc(sizeof(struct disc_softc), M_DISC, M_WAITOK | M_ZERO); ifp = sc->sc_ifp = if_alloc(IFT_LOOP); - if (ifp == NULL) { - free(sc, M_DISC); - return (ENOSPC); - } - ifp->if_softc = sc; if_initname(ifp, discname, unit); ifp->if_mtu = DSMTU; diff --git a/sys/net/if_edsc.c b/sys/net/if_edsc.c index 8a66b462d15..e037db39923 100644 --- a/sys/net/if_edsc.c +++ b/sys/net/if_edsc.c @@ -104,11 +104,6 @@ edsc_clone_create(struct if_clone *ifc, int unit, caddr_t params) */ sc = malloc(sizeof(struct edsc_softc), M_EDSC, M_WAITOK | M_ZERO); ifp = sc->sc_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - free(sc, M_EDSC); - return (ENOSPC); - } - ifp->if_softc = sc; /* diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c index eaac0a84318..18587dc1cb4 100644 --- a/sys/net/if_enc.c +++ b/sys/net/if_enc.c @@ -163,10 +163,6 @@ enc_clone_create(struct if_clone *ifc, int unit, caddr_t params) sc = malloc(sizeof(struct enc_softc), M_DEVBUF, M_WAITOK | M_ZERO); ifp = sc->sc_ifp = if_alloc(IFT_ENC); - if (ifp == NULL) { - free(sc, M_DEVBUF); - return (ENOSPC); - } if (V_enc_sc != NULL) { if_free(ifp); free(sc, M_DEVBUF); diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index 7bc218321f0..7051e31565d 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -516,9 +516,6 @@ epair_alloc_sc(struct if_clone *ifc) struct epair_softc *sc; struct ifnet *ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) - return (NULL); - sc = malloc(sizeof(struct epair_softc), M_EPAIR, M_WAITOK | M_ZERO); sc->ifp = ifp; sc->num_queues = epair_tasks.tasks; @@ -614,8 +611,6 @@ epair_generate_mac(struct epair_softc *sc, uint8_t *eaddr) static void epair_free_sc(struct epair_softc *sc) { - if (sc == NULL) - return; if_free(sc->ifp); ifmedia_removeall(&sc->media); @@ -714,12 +709,6 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, /* Allocate memory for both [ab] interfaces */ sca = epair_alloc_sc(ifc); scb = epair_alloc_sc(ifc); - if (sca == NULL || scb == NULL) { - epair_free_sc(sca); - epair_free_sc(scb); - ifc_free_unit(ifc, unit); - return (ENOSPC); - } /* * Cross-reference the interfaces so we will be able to free both. diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 9746d4115bc..e55b46a047d 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -533,10 +533,6 @@ lagg_clone_create(struct if_clone *ifc, char *name, size_t len, sc = malloc(sizeof(*sc), M_LAGG, M_WAITOK | M_ZERO); ifp = sc->sc_ifp = if_alloc(if_type); - if (ifp == NULL) { - free(sc, M_LAGG); - return (ENOSPC); - } LAGG_SX_INIT(sc); mtx_init(&sc->sc_mtx, "lagg-mtx", NULL, MTX_DEF); diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 5558fe5a71a..27c9281957e 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -125,9 +125,6 @@ lo_clone_create(struct if_clone *ifc, char *name, size_t len, struct ifnet *ifp; ifp = if_alloc(IFT_LOOP); - if (ifp == NULL) - return (ENOSPC); - if_initname(ifp, loname, ifd->unit); ifp->if_mtu = LOMTU; ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index 9f9e57b84f3..6fa3d03d1cf 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -264,11 +264,6 @@ stf_clone_create(struct if_clone *ifc, char *name, size_t len, sc = malloc(sizeof(struct stf_softc), M_STF, M_WAITOK | M_ZERO); ifp = STF2IFP(sc) = if_alloc(IFT_STF); - if (ifp == NULL) { - free(sc, M_STF); - ifc_free_unit(ifc, unit); - return (ENOSPC); - } ifp->if_softc = sc; sc->sc_fibnum = curthread->td_proc->p_fibnum; diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c index 5d37879e87b..54d1908b078 100644 --- a/sys/net/if_tuntap.c +++ b/sys/net/if_tuntap.c @@ -971,9 +971,6 @@ tuncreate(struct cdev *dev) iflags |= IFF_POINTOPOINT; } ifp = tp->tun_ifp = if_alloc(type); - if (ifp == NULL) - panic("%s%d: failed to if_alloc() interface.\n", - drv->cdevsw.d_name, dev2unit(dev)); ifp->if_softc = tp; if_initname(ifp, drv->cdevsw.d_name, dev2unit(dev)); ifp->if_ioctl = tunifioctl; diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index b69d8107e30..59eb41956ad 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1163,14 +1163,6 @@ vlan_clone_create(struct if_clone *ifc, char *name, size_t len, ifv = malloc(sizeof(struct ifvlan), M_VLAN, M_WAITOK | M_ZERO); ifp = ifv->ifv_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - if (!subinterface) - ifc_free_unit(ifc, unit); - free(ifv, M_VLAN); - if (p != NULL) - if_rele(p); - return (ENOSPC); - } CK_SLIST_INIT(&ifv->vlan_mc_listhead); ifp->if_softc = ifv; /* diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c index c6686c4868f..2bde1d894a3 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -3225,11 +3225,6 @@ vxlan_clone_create(struct if_clone *ifc, char *name, size_t len, vxlan_stats_alloc(sc); ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - error = ENOSPC; - goto fail; - } - sc->vxl_ifp = ifp; rm_init(&sc->vxl_lock, "vxlanrm"); callout_init_rw(&sc->vxl_callout, &sc->vxl_lock, 0); diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 01493e90f6b..0dba65fee2d 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -5749,10 +5749,6 @@ iflib_register(if_ctx_t ctx) CTX_LOCK_INIT(ctx); STATE_LOCK_INIT(ctx, device_get_nameunit(ctx->ifc_dev)); ifp = ctx->ifc_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(dev, "can not allocate ifnet structure\n"); - return (ENOMEM); - } /* * Initialize our context's device specific methods diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index 15785a8f096..4afa3f3e974 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -528,10 +528,6 @@ ieee80211_vap_setup(struct ieee80211com *ic, struct ieee80211vap *vap, struct ifnet *ifp; ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - ic_printf(ic, "%s: unable to allocate ifnet\n", __func__); - return ENOMEM; - } if_initname(ifp, name, unit); ifp->if_softc = vap; /* back pointer */ ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c index 40b1a1128de..ae88d1b0785 100644 --- a/sys/netgraph/ng_eiface.c +++ b/sys/netgraph/ng_eiface.c @@ -386,12 +386,7 @@ ng_eiface_constructor(node_p node) /* Allocate node and interface private structures */ priv = malloc(sizeof(*priv), M_NETGRAPH, M_WAITOK | M_ZERO); - ifp = priv->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - free(priv, M_NETGRAPH); - return (ENOSPC); - } /* Link them together */ ifp->if_softc = priv; diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index e9f97ff0fde..d42e74d5fd2 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -524,10 +524,6 @@ ng_iface_constructor(node_p node) /* Allocate node and interface private structures */ priv = malloc(sizeof(*priv), M_NETGRAPH_IFACE, M_WAITOK | M_ZERO); ifp = if_alloc(IFT_PROPVIRTUAL); - if (ifp == NULL) { - free(priv, M_NETGRAPH_IFACE); - return (ENOMEM); - } rm_init(&priv->lock, "ng_iface private rmlock"); diff --git a/sys/netpfil/ipfw/ip_fw_bpf.c b/sys/netpfil/ipfw/ip_fw_bpf.c index 5d27eae4d79..85e0e7cfdc5 100644 --- a/sys/netpfil/ipfw/ip_fw_bpf.c +++ b/sys/netpfil/ipfw/ip_fw_bpf.c @@ -96,8 +96,6 @@ ipfw_clone_create(struct if_clone *ifc, int unit, caddr_t params) struct ifnet *ifp; ifp = if_alloc(IFT_PFLOG); - if (ifp == NULL) - return (ENOSPC); if_initname(ifp, ipfwname, unit); ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_mtu = 65536; @@ -122,8 +120,6 @@ ipfwlog_clone_create(struct if_clone *ifc, int unit, caddr_t params) struct ifnet *ifp; ifp = if_alloc(IFT_PFLOG); - if (ifp == NULL) - return (ENOSPC); if_initname(ifp, ipfwlogname, unit); ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_mtu = 65536; diff --git a/sys/netpfil/pf/if_pflog.c b/sys/netpfil/pf/if_pflog.c index f20dc214f56..53fe36343c7 100644 --- a/sys/netpfil/pf/if_pflog.c +++ b/sys/netpfil/pf/if_pflog.c @@ -129,9 +129,6 @@ pflog_clone_create(struct if_clone *ifc, char *name, size_t maxlen, return (EINVAL); ifp = if_alloc(IFT_PFLOG); - if (ifp == NULL) { - return (ENOSPC); - } if_initname(ifp, pflogname, ifd->unit); ifp->if_mtu = PFLOGMTU; ifp->if_ioctl = pflogioctl; diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index b188813cb8d..9aad44ccaf9 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -396,10 +396,6 @@ pfsync_clone_create(struct if_clone *ifc, int unit, caddr_t param) sc->sc_version = PFSYNC_MSG_VERSION_DEFAULT; ifp = sc->sc_ifp = if_alloc(IFT_PFSYNC); - if (ifp == NULL) { - free(sc, M_PFSYNC); - return (ENOSPC); - } if_initname(ifp, pfsyncname, unit); ifp->if_softc = sc; ifp->if_ioctl = pfsyncioctl; diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c index c8f7574a12f..f3a85f3a0cb 100644 --- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -906,10 +906,6 @@ ipoib_intf_alloc(const char *name, struct ib_device *hca) priv = ipoib_priv_alloc(); dev = priv->dev = if_alloc(IFT_INFINIBAND); - if (!dev) { - free(priv, M_TEMP); - return NULL; - } if_setsoftc(dev, priv); priv->gone = 2; /* initializing */ priv->unit = alloc_unr(ipoib_unrhdr);