rem: dprintf("ipro1000: adapter structure allocation failed\n");
add: ERROROUT("adapter structure allocation failed");
context: em_attach(device_t dev){	struct adapter * adapter;	int             s;	int             tsize, rsize;	int             error = 0;	INIT_DEBUGOUT("em_attach: begin");	s = splimp();	/* Allocate, clear, and link in our adapter structure */	if (!(adapter = device_get_softc(dev))) {		dprintf("ipro1000: adapter structure allocation failed\n");		splx(s);		return(ENOMEM);	}	bzero(adapter, sizeof(struct adapter ));	adapter->dev = dev;	adapter->osdep.dev = dev;	adapter->unit = device_get_unit(dev);	/* SYSCTL stuff */        sysctl_ctx_init(&adapter->sysctl_ctx);        adapter->sysctl_tree = SYSCTL_ADD_NODE(&adapter->sysctl_ctx,					       SYSCTL_STATIC_CHILDREN(_hw),					       OID_AUTO, 					       device_get_nameunit(dev),					       CTLFLAG_RD,					       0, "");        if (adapter->sysctl_tree == NULL) {		error = EIO;		goto err_sysctl;        }         SYSCTL_ADD_PROC(&adapter->sysctl_ctx,  			SYSCTL_CHILDREN(adapter->sysctl_tree),			OID_AUTO, "debug_info", CTLTYPE_INT|CTLFLAG_RW, 			(void *)adapter, 0,                        em_sysctl_debug_info, "I", "Debug Information");	SYSCTL_ADD_PROC(&adapter->sysctl_ctx,  			SYSCTL_CHILDREN(adapter->sysctl_tree),			OID_AUTO, "stats", CTLTYPE_INT|CTLFLAG_RW, 			(void *)adapter, 0,                        em_sysctl_stats, "I", "Statistics");	callout_handle_init(&adapter->timer_handle);	callout_handle_init(&adapter->tx_fifo_timer_handle);	/* create event processing thread */	if (start_event_thread(adapter) < 0) {		error = EIO;		goto err_event;	}	/* Determine hardware revision */	em_identify_hardware(adapter);      	/* Set up some sysctls for the tunable interrupt delays */        em_add_int_delay_sysctl(adapter, "rx_int_delay",            "receive interrupt delay in usecs", &adapter->rx_int_delay,            E1000_REG_OFFSET(&adapter->hw, RDTR), em_rx_int_delay_dflt);        em_add_int_delay_sysctl(adapter, "tx_int_delay",            "transmit interrupt delay in usecs", &adapter->tx_int_delay,            E1000_REG_OFFSET(&adapter->hw, TIDV), em_tx_int_delay_dflt);        if (adapter->hw.mac_type >= em_82540) {                em_add_int_delay_sysctl(adapter, "rx_abs_int_delay",                    "receive interrupt delay limit in usecs",                    &adapter->rx_abs_int_delay,                    E1000_REG_OFFSET(&adapter->hw, RADV),                    em_rx_abs_int_delay_dflt);                em_add_int_delay_sysctl(adapter, "tx_abs_int_delay",                    "transmit interrupt delay limit in usecs",                    &adapter->tx_abs_int_delay,                    E1000_REG_OFFSET(&adapter->hw, TADV),                    em_tx_abs_int_delay_dflt);        }	/* Parameters (to be read from user) */           adapter->num_tx_desc = EM_MAX_TXD;        adapter->num_rx_desc = EM_MAX_RXD;        adapter->hw.autoneg = DO_AUTO_NEG;        adapter->hw.wait_autoneg_complete = WAIT_FOR_AUTO_NEG_DEFAULT;        adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT;        adapter->hw.tbi_compatibility_en = TRUE;        adapter->rx_buffer_len = EM_RXBUFFER_2048;	                        	/* 	 * These parameters control the automatic generation(Tx) and 	 * response(Rx) to Ethernet PAUSE frames.	 */        adapter->hw.fc_high_water = FC_DEFAULT_HI_THRESH;        adapter->hw.fc_low_water  = FC_DEFAULT_LO_THRESH;        adapter->hw.fc_pause_time = FC_DEFAULT_TX_TIMER;        adapter->hw.fc_send_xon   = TRUE;        adapter->hw.fc = em_fc_full;		adapter->hw.phy_init_script = 1;	adapter->hw.phy_reset_disable = FALSE;#ifndef EM_MASTER_SLAVE	adapter->hw.master_slave = em_ms_hw_default;#else	adapter->hw.master_slave = EM_MASTER_SLAVE;#endif	/* 	 * Set the max frame size assuming standard ethernet 	 * sized frames 	 */   	adapter->hw.max_frame_size = 		ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN;	adapter->hw.min_frame_size = 		MINIMUM_ETHERNET_PACKET_SIZE + ETHER_CRC_LEN;	/* 	 * This controls when hardware reports transmit completion 	 * status. 	 */	adapter->hw.report_tx_early = 1;	if (em_allocate_pci_resources(adapter)) {		dprintf("ipro1000/%d: Allocation of PCI resources failed\n", 		       adapter->unit);		error = ENXIO;		goto err_pci;	}  	        em_init_eeprom_params(&adapter->hw);	tsize = EM_ROUNDUP(adapter->num_tx_desc *			   sizeof(struct em_tx_desc), 4096);	/* Allocate Transmit Descriptor ring */	if (!(adapter->tx_desc_base = (struct em_tx_desc *)	      contigmalloc(tsize, M_DEVBUF, M_NOWAIT, 0, ~0, 			   PAGE_SIZE, 0))) {		dprintf("ipro1000/%d: Unable to allocate TxDescriptor memory\n", 		       adapter->unit);		error = ENOMEM;		goto err_tx_desc;	}	rsize = EM_ROUNDUP(adapter->num_rx_desc *			   sizeof(struct em_rx_desc), 4096);	/* Allocate Receive Descriptor ring */	if (!(adapter->rx_desc_base = (struct em_rx_desc *)	      contigmalloc(rsize, M_DEVBUF, M_NOWAIT, 0, ~0, 			   PAGE_SIZE, 0))) {		dprintf("ipro1000/%d: Unable to allocate rx_desc memory\n", 		       adapter->unit);		error = ENOMEM;		goto err_rx_desc;	}	/* Initialize the hardware */	if (em_hardware_init(adapter)) {		dprintf("ipro1000/%d: Unable to initialize the hardware\n",		       adapter->unit);		error = EIO;		goto err_hw_init;	}	/* Copy the permanent MAC address out of the EEPROM */	if (em_read_mac_addr(&adapter->hw) < 0) {		dprintf("ipro1000/%d: EEPROM read error while reading mac address\n",		       adapter->unit);		error = EIO;		goto err_mac_addr;	}	if (!em_is_valid_ether_addr(adapter->hw.mac_addr)) {		dprintf("ipro1000/%d: Invalid mac address\n", adapter->unit);		error = EIO;		goto err_mac_addr;	}	bcopy(adapter->hw.mac_addr, adapter->interface_data.ac_enaddr,	      ETHER_ADDR_LEN);	/* Setup OS specific network interface */	em_setup_interface(dev, adapter);	/* Initialize statistics */	em_clear_hw_cntrs(&adapter->hw);	em_update_stats_counters(adapter);	adapter->hw.get_link_status = 1;	em_check_for_link(&adapter->hw);	/* Print the link status */	if (adapter->link_active == 1) {		em_get_speed_and_duplex(&adapter->hw, &adapter->link_speed, 					&adapter->link_duplex);		dprintf("ipro1000/%d:  Speed:%d Mbps  Duplex:%s\n",		       adapter->unit,		       adapter->link_speed,		       adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half");	} else		dprintf("ipro1000/%d:  Speed:N/A  Duplex:N/A\n", adapter->unit);	/* Identify 82544 on PCIX */ 	em_get_bus_info(&adapter->hw);		if(adapter->hw.bus_type == em_bus_type_pcix &&           adapter->hw.mac_type == em_82544) {                adapter->pcix_82544 = TRUE;	}        else {                adapter->pcix_82544 = FALSE; 	}		INIT_DEBUGOUT("em_attach: end");	splx(s);	return(error);err_mac_addr:err_hw_init:	contigfree(adapter->rx_desc_base, rsize, M_DEVBUF);err_rx_desc:	contigfree(adapter->tx_desc_base, tsize, M_DEVBUF);err_tx_desc:err_pci:	em_free_pci_resources(adapter);err_event:	sysctl_ctx_free(&adapter->sysctl_ctx);err_sysctl:        splx(s);	return(error);}