Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752501AbbHCBg6 (ORCPT ); Sun, 2 Aug 2015 21:36:58 -0400 Received: from m50-133.163.com ([123.125.50.133]:50157 "EHLO m50-133.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750924AbbHCBg4 (ORCPT ); Sun, 2 Aug 2015 21:36:56 -0400 From: Jia-Ju Bai To: jeffrey.t.kirsher@intel.com, jesse.brandeburg@intel.com Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH]Fix a null dereference in e1000_open Date: Mon, 3 Aug 2015 09:36:26 +0800 Message-Id: <1438565786-5070-1-git-send-email-baijiaju1990@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: DdGowEBpIFejxb5VCJeaAA--.47S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7Xr43tFWrAry8Jry3KF13CFg_yoWkKrX_ur 1kur1xJrW5Aa4F9F1rZr47A34j9r1DXa97ZFyft393uFnrAr48Wwn5Wry7WF1Sga4rZFWk Jry3XFW5Aw4FkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnZvtJUUUUU== X-Originating-IP: [173.252.200.40] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiTg5LelUCnHHNtQAAsz Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1369 Lines: 36 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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/