Fixed possible segfault in e1000_open() function.
--- a/devices/e1000/e1000_main-2.6.24-ethercat.c Wed Dec 05 10:22:43 2012 +0100
+++ b/devices/e1000/e1000_main-2.6.24-ethercat.c Wed Dec 05 11:28:29 2012 +0100
@@ -1479,7 +1479,9 @@
clear_bit(__E1000_DOWN, &adapter->flags);
#ifdef CONFIG_E1000_NAPI
- napi_enable(&adapter->napi);
+ if (!adapter->ecdev) {
+ napi_enable(&adapter->napi);
+ }
#endif
e1000_irq_enable(adapter);
--- a/devices/e1000/e1000_main-2.6.26-ethercat.c Wed Dec 05 10:22:43 2012 +0100
+++ b/devices/e1000/e1000_main-2.6.26-ethercat.c Wed Dec 05 11:28:29 2012 +0100
@@ -1544,7 +1544,9 @@
clear_bit(__E1000_DOWN, &adapter->flags);
#ifdef CONFIG_E1000_NAPI
- napi_enable(&adapter->napi);
+ if (!adapter->ecdev) {
+ napi_enable(&adapter->napi);
+ }
#endif
e1000_irq_enable(adapter);
--- a/devices/e1000/e1000_main-2.6.27-ethercat.c Wed Dec 05 10:22:43 2012 +0100
+++ b/devices/e1000/e1000_main-2.6.27-ethercat.c Wed Dec 05 11:28:29 2012 +0100
@@ -1531,11 +1531,13 @@
/* From here on the code is the same as e1000_up() */
clear_bit(__E1000_DOWN, &adapter->flags);
- napi_enable(&adapter->napi);
-
- e1000_irq_enable(adapter);
-
- netif_start_queue(netdev);
+ if (!adapter->ecdev) {
+ napi_enable(&adapter->napi);
+
+ e1000_irq_enable(adapter);
+
+ netif_start_queue(netdev);
+ }
/* fire a link status change interrupt to start the watchdog */
ew32(ICS, E1000_ICS_LSC);
--- a/devices/e1000/e1000_main-2.6.28-ethercat.c Wed Dec 05 10:22:43 2012 +0100
+++ b/devices/e1000/e1000_main-2.6.28-ethercat.c Wed Dec 05 11:28:29 2012 +0100
@@ -1529,11 +1529,13 @@
/* From here on the code is the same as e1000_up() */
clear_bit(__E1000_DOWN, &adapter->flags);
- napi_enable(&adapter->napi);
-
- e1000_irq_enable(adapter);
-
- netif_start_queue(netdev);
+ if (!adapter->ecdev) {
+ napi_enable(&adapter->napi);
+
+ e1000_irq_enable(adapter);
+
+ netif_start_queue(netdev);
+ }
/* fire a link status change interrupt to start the watchdog */
ew32(ICS, E1000_ICS_LSC);
--- a/devices/e1000/e1000_main-2.6.29-ethercat.c Wed Dec 05 10:22:43 2012 +0100
+++ b/devices/e1000/e1000_main-2.6.29-ethercat.c Wed Dec 05 11:28:29 2012 +0100
@@ -496,7 +496,7 @@
/* fill rx ring completely! */
adapter->alloc_rx_buf(adapter, ring, ring->count);
} else {
- /* this one leaves the last ring element unallocated! */
+ /* this one leaves the last ring element unallocated! */
adapter->alloc_rx_buf(adapter, ring,
E1000_DESC_UNUSED(ring));
}
@@ -618,7 +618,7 @@
netdev->tx_queue_len = adapter->tx_queue_len;
adapter->link_speed = 0;
adapter->link_duplex = 0;
- if (!adapter->ecdev) {
+ if (!adapter->ecdev) {
netif_carrier_off(netdev);
netif_stop_queue(netdev);
}
@@ -1245,14 +1245,14 @@
!e1000_check_mng_mode(hw))
e1000_get_hw_control(adapter);
- // offer device to EtherCAT master module
- adapter->ecdev = ecdev_offer(netdev, ec_poll, THIS_MODULE);
- if (adapter->ecdev) {
- if (ecdev_open(adapter->ecdev)) {
- ecdev_withdraw(adapter->ecdev);
- goto err_register;
- }
- } else {
+ // offer device to EtherCAT master module
+ adapter->ecdev = ecdev_offer(netdev, ec_poll, THIS_MODULE);
+ if (adapter->ecdev) {
+ if (ecdev_open(adapter->ecdev)) {
+ ecdev_withdraw(adapter->ecdev);
+ goto err_register;
+ }
+ } else {
/* tell the stack to leave us alone until e1000_open() is called */
netif_carrier_off(netdev);
netif_stop_queue(netdev);
@@ -1261,7 +1261,7 @@
err = register_netdev(netdev);
if (err)
goto err_register;
- }
+ }
DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
@@ -1505,11 +1505,13 @@
/* From here on the code is the same as e1000_up() */
clear_bit(__E1000_DOWN, &adapter->flags);
- napi_enable(&adapter->napi);
-
- e1000_irq_enable(adapter);
-
- netif_start_queue(netdev);
+ if (!adapter->ecdev) {
+ napi_enable(&adapter->napi);
+
+ e1000_irq_enable(adapter);
+
+ netif_start_queue(netdev);
+ }
/* fire a link status change interrupt to start the watchdog */
ew32(ICS, E1000_ICS_LSC);
@@ -2300,7 +2302,7 @@
/* fill rx ring completely! */
adapter->alloc_rx_buf(adapter, ring, ring->count);
} else {
- /* this one leaves the last ring element unallocated! */
+ /* this one leaves the last ring element unallocated! */
adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring));
}
@@ -2638,7 +2640,7 @@
adapter->link_duplex = 0;
printk(KERN_INFO "e1000: %s NIC Link is Down\n",
netdev->name);
- if (adapter->ecdev) {
+ if (adapter->ecdev) {
ecdev_set_link(adapter->ecdev, 0);
} else {
netif_carrier_off(netdev);
@@ -3353,8 +3355,8 @@
(hw->mac_type == e1000_82573))
e1000_transfer_dhcp_info(adapter, skb);
- if (!adapter->ecdev &&
- !spin_trylock_irqsave(&tx_ring->tx_lock, flags))
+ if (!adapter->ecdev &&
+ !spin_trylock_irqsave(&tx_ring->tx_lock, flags))
/* Collision - tell upper layer to requeue */
return NETDEV_TX_LOCKED;
@@ -3735,17 +3737,17 @@
void ec_poll(struct net_device *netdev)
{
- struct e1000_adapter *adapter = netdev_priv(netdev);
-
- if (jiffies - adapter->ec_watchdog_jiffies >= 2 * HZ) {
- e1000_watchdog((unsigned long) adapter);
- adapter->ec_watchdog_jiffies = jiffies;
- }
+ struct e1000_adapter *adapter = netdev_priv(netdev);
+
+ if (jiffies - adapter->ec_watchdog_jiffies >= 2 * HZ) {
+ e1000_watchdog((unsigned long) adapter);
+ adapter->ec_watchdog_jiffies = jiffies;
+ }
#ifdef CONFIG_PCI_MSI
e1000_intr_msi(0, netdev);
#else
- e1000_intr(0, netdev);
+ e1000_intr(0, netdev);
#endif
}
@@ -3762,16 +3764,16 @@
struct e1000_hw *hw = &adapter->hw;
u32 icr = er32(ICR);
- if (adapter->ecdev) {
- int i, ec_work_done = 0;
- for (i = 0; i < E1000_MAX_INTR; i++) {
- if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring,
- &ec_work_done, 100) &&
- !e1000_clean_tx_irq(adapter, adapter->tx_ring))) {
- break;
- }
- }
- } else {
+ if (adapter->ecdev) {
+ int i, ec_work_done = 0;
+ for (i = 0; i < E1000_MAX_INTR; i++) {
+ if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring,
+ &ec_work_done, 100) &&
+ !e1000_clean_tx_irq(adapter, adapter->tx_ring))) {
+ break;
+ }
+ }
+ } else {
/* in NAPI mode read ICR disables interrupts using IAM */
if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
@@ -4135,7 +4137,7 @@
}
if (!adapter->ecdev &&
- unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
+ unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
last_byte = *(skb->data + length - 1);
if (TBI_ACCEPT(hw, status, rx_desc->errors, length,
last_byte)) {
--- a/devices/e1000/e1000_main-2.6.31-ethercat.c Wed Dec 05 10:22:43 2012 +0100
+++ b/devices/e1000/e1000_main-2.6.31-ethercat.c Wed Dec 05 11:28:29 2012 +0100
@@ -1525,11 +1525,13 @@
/* From here on the code is the same as e1000_up() */
clear_bit(__E1000_DOWN, &adapter->flags);
- napi_enable(&adapter->napi);
-
- e1000_irq_enable(adapter);
-
- netif_start_queue(netdev);
+ if (!adapter->ecdev) {
+ napi_enable(&adapter->napi);
+
+ e1000_irq_enable(adapter);
+
+ netif_start_queue(netdev);
+ }
/* fire a link status change interrupt to start the watchdog */
ew32(ICS, E1000_ICS_LSC);
--- a/devices/e1000/e1000_main-2.6.32-ethercat.c Wed Dec 05 10:22:43 2012 +0100
+++ b/devices/e1000/e1000_main-2.6.32-ethercat.c Wed Dec 05 11:28:29 2012 +0100
@@ -1332,11 +1332,13 @@
/* From here on the code is the same as e1000_up() */
clear_bit(__E1000_DOWN, &adapter->flags);
- napi_enable(&adapter->napi);
-
- e1000_irq_enable(adapter);
-
- netif_start_queue(netdev);
+ if (!adapter->ecdev) {
+ napi_enable(&adapter->napi);
+
+ e1000_irq_enable(adapter);
+
+ netif_start_queue(netdev);
+ }
/* fire a link status change interrupt to start the watchdog */
ew32(ICS, E1000_ICS_LSC);
--- a/devices/e1000/e1000_main-2.6.33-ethercat.c Wed Dec 05 10:22:43 2012 +0100
+++ b/devices/e1000/e1000_main-2.6.33-ethercat.c Wed Dec 05 11:28:29 2012 +0100
@@ -1332,11 +1332,13 @@
/* From here on the code is the same as e1000_up() */
clear_bit(__E1000_DOWN, &adapter->flags);
- napi_enable(&adapter->napi);
-
- e1000_irq_enable(adapter);
-
- netif_start_queue(netdev);
+ if (!adapter->ecdev) {
+ napi_enable(&adapter->napi);
+
+ e1000_irq_enable(adapter);
+
+ netif_start_queue(netdev);
+ }
/* fire a link status change interrupt to start the watchdog */
ew32(ICS, E1000_ICS_LSC);
--- a/devices/e1000/e1000_main-2.6.35-ethercat.c Wed Dec 05 10:22:43 2012 +0100
+++ b/devices/e1000/e1000_main-2.6.35-ethercat.c Wed Dec 05 11:28:29 2012 +0100
@@ -1338,11 +1338,13 @@
/* From here on the code is the same as e1000_up() */
clear_bit(__E1000_DOWN, &adapter->flags);
- napi_enable(&adapter->napi);
-
- e1000_irq_enable(adapter);
-
- netif_start_queue(netdev);
+ if (!adapter->ecdev) {
+ napi_enable(&adapter->napi);
+
+ e1000_irq_enable(adapter);
+
+ netif_start_queue(netdev);
+ }
/* fire a link status change interrupt to start the watchdog */
ew32(ICS, E1000_ICS_LSC);
--- a/devices/e1000/e1000_main-2.6.37-ethercat.c Wed Dec 05 10:22:43 2012 +0100
+++ b/devices/e1000/e1000_main-2.6.37-ethercat.c Wed Dec 05 11:28:29 2012 +0100
@@ -1356,7 +1356,9 @@
if (test_bit(__E1000_TESTING, &adapter->flags))
return -EBUSY;
- netif_carrier_off(netdev);
+ if (!adapter->ecdev) {
+ netif_carrier_off(netdev);
+ }
/* allocate transmit descriptors */
err = e1000_setup_all_tx_resources(adapter);
@@ -1389,11 +1391,13 @@
/* From here on the code is the same as e1000_up() */
clear_bit(__E1000_DOWN, &adapter->flags);
- napi_enable(&adapter->napi);
-
- e1000_irq_enable(adapter);
-
- netif_start_queue(netdev);
+ if (!adapter->ecdev) {
+ napi_enable(&adapter->napi);
+
+ e1000_irq_enable(adapter);
+
+ netif_start_queue(netdev);
+ }
/* fire a link status change interrupt to start the watchdog */
ew32(ICS, E1000_ICS_LSC);
--- a/devices/e1000/e1000_main-3.0-ethercat.c Wed Dec 05 10:22:43 2012 +0100
+++ b/devices/e1000/e1000_main-3.0-ethercat.c Wed Dec 05 11:28:29 2012 +0100
@@ -1423,11 +1423,13 @@
/* From here on the code is the same as e1000_up() */
clear_bit(__E1000_DOWN, &adapter->flags);
- napi_enable(&adapter->napi);
-
- e1000_irq_enable(adapter);
-
- netif_start_queue(netdev);
+ if (!adapter->ecdev) {
+ napi_enable(&adapter->napi);
+
+ e1000_irq_enable(adapter);
+
+ netif_start_queue(netdev);
+ }
/* fire a link status change interrupt to start the watchdog */
ew32(ICS, E1000_ICS_LSC);