Do not call voluntary panic(9) in case of if_alloc() failure.
Reviewed by: jfv
This commit is contained in:
parent
5c8080f0d9
commit
ad1917be37
@ -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 @@ em_attach(device_t dev)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 @@ igb_attach(device_t dev)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 @@ lem_attach(device_t dev)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,7 +108,7 @@ static int ixgb_allocate_pci_resources(struct adapter *);
|
||||
static void ixgb_free_pci_resources(struct adapter *);
|
||||
static void ixgb_local_timer(void *);
|
||||
static int ixgb_hardware_init(struct adapter *);
|
||||
static void ixgb_setup_interface(device_t, struct adapter *);
|
||||
static int ixgb_setup_interface(device_t, struct adapter *);
|
||||
static int ixgb_setup_transmit_structures(struct adapter *);
|
||||
static void ixgb_initialize_transmit_unit(struct adapter *);
|
||||
static int ixgb_setup_receive_structures(struct adapter *);
|
||||
@ -331,7 +331,8 @@ ixgb_attach(device_t dev)
|
||||
goto err_hw_init;
|
||||
}
|
||||
/* Setup OS specific network interface */
|
||||
ixgb_setup_interface(dev, adapter);
|
||||
if (ixgb_setup_interface(dev, adapter) != 0)
|
||||
goto err_hw_init;
|
||||
|
||||
/* Initialize statistics */
|
||||
ixgb_clear_hw_cntrs(&adapter->hw);
|
||||
@ -346,6 +347,8 @@ ixgb_attach(device_t dev)
|
||||
ixgb_dma_free(adapter, &adapter->txdma);
|
||||
err_tx_desc:
|
||||
err_pci:
|
||||
if (adapter->ifp != NULL)
|
||||
if_free(adapter->ifp);
|
||||
ixgb_free_pci_resources(adapter);
|
||||
sysctl_ctx_free(&adapter->sysctl_ctx);
|
||||
return (error);
|
||||
@ -1319,15 +1322,17 @@ ixgb_hardware_init(struct adapter * adapter)
|
||||
* Setup networking device structure and register an interface.
|
||||
*
|
||||
**********************************************************************/
|
||||
static void
|
||||
static int
|
||||
ixgb_setup_interface(device_t dev, struct adapter * adapter)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
INIT_DEBUGOUT("ixgb_setup_interface: begin");
|
||||
|
||||
ifp = adapter->ifp = if_alloc(IFT_ETHER);
|
||||
if (ifp == NULL)
|
||||
panic("%s: can not if_alloc()\n", device_get_nameunit(dev));
|
||||
if (ifp == NULL) {
|
||||
device_printf(dev, "can not allocate ifnet structure\n");
|
||||
return (-1);
|
||||
}
|
||||
#if __FreeBSD_version >= 502000
|
||||
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
||||
#else
|
||||
@ -1379,7 +1384,7 @@ ixgb_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;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
@ -119,7 +119,7 @@ static int ixgbe_allocate_queues(struct adapter *);
|
||||
static int ixgbe_setup_msix(struct adapter *);
|
||||
static void ixgbe_free_pci_resources(struct adapter *);
|
||||
static void ixgbe_local_timer(void *);
|
||||
static void ixgbe_setup_interface(device_t, struct adapter *);
|
||||
static int ixgbe_setup_interface(device_t, struct adapter *);
|
||||
static void ixgbe_config_link(struct adapter *);
|
||||
|
||||
static int ixgbe_allocate_transmit_buffers(struct tx_ring *);
|
||||
@ -586,7 +586,8 @@ ixgbe_attach(device_t dev)
|
||||
goto err_late;
|
||||
|
||||
/* Setup OS specific network interface */
|
||||
ixgbe_setup_interface(dev, adapter);
|
||||
if (ixgbe_setup_interface(dev, adapter) != 0)
|
||||
goto err_late;
|
||||
|
||||
/* Sysctl for limiting the amount of work done in the taskqueue */
|
||||
ixgbe_add_rx_process_limit(adapter, "rx_processing_limit",
|
||||
@ -632,6 +633,8 @@ ixgbe_attach(device_t dev)
|
||||
ixgbe_free_transmit_structures(adapter);
|
||||
ixgbe_free_receive_structures(adapter);
|
||||
err_out:
|
||||
if (adapter->ifp != NULL)
|
||||
if_free(adapter->ifp);
|
||||
ixgbe_free_pci_resources(adapter);
|
||||
return (error);
|
||||
|
||||
@ -2357,7 +2360,7 @@ ixgbe_free_pci_resources(struct adapter * adapter)
|
||||
* Setup networking device structure and register an interface.
|
||||
*
|
||||
**********************************************************************/
|
||||
static void
|
||||
static int
|
||||
ixgbe_setup_interface(device_t dev, struct adapter *adapter)
|
||||
{
|
||||
struct ixgbe_hw *hw = &adapter->hw;
|
||||
@ -2366,8 +2369,10 @@ ixgbe_setup_interface(device_t dev, struct adapter *adapter)
|
||||
INIT_DEBUGOUT("ixgbe_setup_interface: begin");
|
||||
|
||||
ifp = adapter->ifp = if_alloc(IFT_ETHER);
|
||||
if (ifp == NULL)
|
||||
panic("%s: can not if_alloc()\n", 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_baudrate = 1000000000;
|
||||
@ -2415,7 +2420,7 @@ ixgbe_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;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user