diff options
author | yongari <yongari@FreeBSD.org> | 2010-08-28 00:09:19 +0000 |
---|---|---|
committer | yongari <yongari@FreeBSD.org> | 2010-08-28 00:09:19 +0000 |
commit | 56b7a9338b535252cfff58d511fe1caf62c44be7 (patch) | |
tree | 39f4093f85ed40455ad12783bf77c4ec4cd006dc /sys/dev/e1000 | |
parent | 3042945d009442792cd49093d9a4e06fabe532cd (diff) | |
download | FreeBSD-src-56b7a9338b535252cfff58d511fe1caf62c44be7.zip FreeBSD-src-56b7a9338b535252cfff58d511fe1caf62c44be7.tar.gz |
Do not call voluntary panic(9) in case of if_alloc() failure.
Reviewed by: jfv
Diffstat (limited to 'sys/dev/e1000')
-rw-r--r-- | sys/dev/e1000/if_em.c | 16 | ||||
-rw-r--r-- | sys/dev/e1000/if_igb.c | 16 | ||||
-rw-r--r-- | sys/dev/e1000/if_lem.c | 16 |
3 files changed, 33 insertions, 15 deletions
diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index e520512..86f28e3 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -213,7 +213,7 @@ static int em_setup_msix(struct adapter *); static void em_free_pci_resources(struct adapter *); static void em_local_timer(void *); static void em_reset(struct adapter *); -static void em_setup_interface(device_t, struct adapter *); +static int em_setup_interface(device_t, struct adapter *); static void em_setup_transmit_structures(struct adapter *); static void em_initialize_transmit_unit(struct adapter *); @@ -628,7 +628,8 @@ em_attach(device_t dev) em_get_wakeup(dev); /* Setup OS specific network interface */ - em_setup_interface(dev, adapter); + if (em_setup_interface(dev, adapter) != 0) + goto err_late; em_reset(adapter); @@ -669,6 +670,8 @@ err_late: em_free_transmit_structures(adapter); em_free_receive_structures(adapter); em_release_hw_control(adapter); + if (adapter->ifp != NULL) + if_free(adapter->ifp); err_pci: em_free_pci_resources(adapter); EM_CORE_LOCK_DESTROY(adapter); @@ -2646,7 +2649,7 @@ em_reset(struct adapter *adapter) * Setup networking device structure and register an interface. * **********************************************************************/ -static void +static int em_setup_interface(device_t dev, struct adapter *adapter) { struct ifnet *ifp; @@ -2654,8 +2657,10 @@ em_setup_interface(device_t dev, struct adapter *adapter) INIT_DEBUGOUT("em_setup_interface: begin"); ifp = adapter->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) - panic("%s: can not if_alloc()", device_get_nameunit(dev)); + if (ifp == NULL) { + device_printf(dev, "can not allocate ifnet structure\n"); + return (-1); + } if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_init = em_init; @@ -2742,6 +2747,7 @@ em_setup_interface(device_t dev, struct adapter *adapter) } ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); + return (0); } diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c index fd8804a..d8371af 100644 --- a/sys/dev/e1000/if_igb.c +++ b/sys/dev/e1000/if_igb.c @@ -178,7 +178,7 @@ static int igb_setup_msix(struct adapter *); static void igb_free_pci_resources(struct adapter *); static void igb_local_timer(void *); static void igb_reset(struct adapter *); -static void igb_setup_interface(device_t, struct adapter *); +static int igb_setup_interface(device_t, struct adapter *); static int igb_allocate_queues(struct adapter *); static void igb_configure_queues(struct adapter *); @@ -564,7 +564,8 @@ igb_attach(device_t dev) goto err_late; /* Setup OS specific network interface */ - igb_setup_interface(dev, adapter); + if (igb_setup_interface(dev, adapter) != 0) + goto err_late; /* Now get a good starting state */ igb_reset(adapter); @@ -613,6 +614,8 @@ err_late: igb_free_transmit_structures(adapter); igb_free_receive_structures(adapter); igb_release_hw_control(adapter); + if (adapter->ifp != NULL) + if_free(adapter->ifp); err_pci: igb_free_pci_resources(adapter); IGB_CORE_LOCK_DESTROY(adapter); @@ -2658,7 +2661,7 @@ igb_reset(struct adapter *adapter) * Setup networking device structure and register an interface. * **********************************************************************/ -static void +static int igb_setup_interface(device_t dev, struct adapter *adapter) { struct ifnet *ifp; @@ -2666,8 +2669,10 @@ igb_setup_interface(device_t dev, struct adapter *adapter) INIT_DEBUGOUT("igb_setup_interface: begin"); ifp = adapter->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) - panic("%s: can not if_alloc()", device_get_nameunit(dev)); + if (ifp == NULL) { + device_printf(dev, "can not allocate ifnet structure\n"); + return (-1); + } if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_init = igb_init; @@ -2744,6 +2749,7 @@ igb_setup_interface(device_t dev, struct adapter *adapter) } ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); + return (0); } diff --git a/sys/dev/e1000/if_lem.c b/sys/dev/e1000/if_lem.c index 1f03f7b..f5c9e293 100644 --- a/sys/dev/e1000/if_lem.c +++ b/sys/dev/e1000/if_lem.c @@ -186,7 +186,7 @@ static int lem_allocate_irq(struct adapter *adapter); static void lem_free_pci_resources(struct adapter *); static void lem_local_timer(void *); static int lem_hardware_init(struct adapter *); -static void lem_setup_interface(device_t, struct adapter *); +static int lem_setup_interface(device_t, struct adapter *); static void lem_setup_transmit_structures(struct adapter *); static void lem_initialize_transmit_unit(struct adapter *); static int lem_setup_receive_structures(struct adapter *); @@ -620,7 +620,8 @@ lem_attach(device_t dev) lem_get_wakeup(dev); /* Setup OS specific network interface */ - lem_setup_interface(dev, adapter); + if (lem_setup_interface(dev, adapter) != 0) + goto err_rx_struct; /* Initialize statistics */ lem_update_stats_counters(adapter); @@ -672,6 +673,8 @@ err_rx_desc: lem_dma_free(adapter, &adapter->txdma); err_tx_desc: err_pci: + if (adapter->ifp != NULL) + if_free(adapter->ifp); lem_free_pci_resources(adapter); EM_TX_LOCK_DESTROY(adapter); EM_RX_LOCK_DESTROY(adapter); @@ -2388,7 +2391,7 @@ lem_hardware_init(struct adapter *adapter) * Setup networking device structure and register an interface. * **********************************************************************/ -static void +static int lem_setup_interface(device_t dev, struct adapter *adapter) { struct ifnet *ifp; @@ -2396,8 +2399,10 @@ lem_setup_interface(device_t dev, struct adapter *adapter) INIT_DEBUGOUT("lem_setup_interface: begin"); ifp = adapter->ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) - panic("%s: can not if_alloc()", device_get_nameunit(dev)); + if (ifp == NULL) { + device_printf(dev, "can not allocate ifnet structure\n"); + return (-1); + } if_initname(ifp, device_get_name(dev), device_get_unit(dev)); ifp->if_mtu = ETHERMTU; ifp->if_init = lem_init; @@ -2473,6 +2478,7 @@ lem_setup_interface(device_t dev, struct adapter *adapter) } ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL); ifmedia_set(&adapter->media, IFM_ETHER | IFM_AUTO); + return (0); } |