[PATCH]Fix a null dereference in e1000_open

2015-08-02 Thread Jia-Ju Bai
When e1000e_setup_rx_resources is failed in e1000_open,
e1000e_free_tx_resources in "err_setup_rx" segment is executed.
"writel(0, tx_ring->head)" statement in e1000_clean_tx_ring
in e1000e_free_tx_resources will cause a null dereference(crash), 
because "tx_ring->head" is only assigned in e1000_configure_tx
in e1000_configure, but it is after e1000e_setup_rx_resources.
This patch adds a check to fix it.

Signed-off-by: Jia-Ju Bai 
---
 drivers/net/ethernet/intel/e1000e/netdev.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c 
b/drivers/net/ethernet/intel/e1000e/netdev.c
index 89d788d..838ec8e 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -2448,7 +2448,8 @@ static void e1000_clean_tx_ring(struct e1000_ring 
*tx_ring)
tx_ring->next_to_use = 0;
tx_ring->next_to_clean = 0;
 
-   writel(0, tx_ring->head);
+   if (tx_ring->head)
+   writel(0, tx_ring->head);
if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
e1000e_update_tdt_wa(tx_ring, 0);
else
-- 
1.7.9.5


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH]Fix a null dereference in e1000_open

2015-08-02 Thread Jia-Ju Bai
When e1000e_setup_rx_resources is failed in e1000_open,
e1000e_free_tx_resources in err_setup_rx segment is executed.
writel(0, tx_ring-head) statement in e1000_clean_tx_ring
in e1000e_free_tx_resources will cause a null dereference(crash), 
because tx_ring-head is only assigned in e1000_configure_tx
in e1000_configure, but it is after e1000e_setup_rx_resources.
This patch adds a check to fix it.

Signed-off-by: Jia-Ju Bai baijiaju1...@163.com
---
 drivers/net/ethernet/intel/e1000e/netdev.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c 
b/drivers/net/ethernet/intel/e1000e/netdev.c
index 89d788d..838ec8e 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -2448,7 +2448,8 @@ static void e1000_clean_tx_ring(struct e1000_ring 
*tx_ring)
tx_ring-next_to_use = 0;
tx_ring-next_to_clean = 0;
 
-   writel(0, tx_ring-head);
+   if (tx_ring-head)
+   writel(0, tx_ring-head);
if (adapter-flags2  FLAG2_PCIM2PCI_ARBITER_WA)
e1000e_update_tdt_wa(tx_ring, 0);
else
-- 
1.7.9.5


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/