From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jia-Ju Bai" Subject: [PATCH] e1000 in linux-3.18.0: a potential bug Date: Sat, 20 Dec 2014 15:50:43 +0800 Message-ID: <000d01d01c29$a9edb870$fdc92950$@163.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: , To: , Return-path: Received: from m50-134.163.com ([123.125.50.134]:51223 "EHLO m50-134.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750780AbaLTHvs (ORCPT ); Sat, 20 Dec 2014 02:51:48 -0500 Content-Language: zh-cn Sender: netdev-owner@vger.kernel.org List-ID: I have actually tested e1000 driver on the real hardware(Intel 82540EM PCI Gigabit Ethernet Controller), and find a potential bug: The target file is drivers/net/ethernet/intel/e1000/e1000_main.c, which is used to build e1000.ko. (1) In the normal process, netif_napi_add is called in e1000_probe, but netif_napi_del is not called in e1000_remove. However, many other ethernet card drivers call them in pairs, even in the error handling paths, such as r8169 and igb. Meanwhile, I also write the patch to fix the bug. I have run the patch on the hardware, it can work normally and fix the above bug. diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index 24f3986..f6def7b 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -1004,7 +1004,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* make ready for any if (hw->...) below */ err = e1000_init_hw_struct(adapter, hw); if (err) - goto err_sw_init; + goto err_dma; /* there is a workaround being applied below that limits * 64-bit DMA addresses to 64-bit hardware. There are some @@ -1239,8 +1239,9 @@ err_eeprom: iounmap(hw->flash_address); kfree(adapter->tx_ring); kfree(adapter->rx_ring); -err_dma: err_sw_init: + netif_napi_del(&adapter->napi); +err_dma: err_mdio_ioremap: iounmap(hw->ce4100_gbe_mdio_base_virt); iounmap(hw->hw_addr); @@ -1271,6 +1272,7 @@ static void e1000_remove(struct pci_dev *pdev) e1000_down_and_stop(adapter); e1000_release_manageability(adapter); + netif_napi_del(&adapter->napi); unregister_netdev(netdev); e1000_phy_hw_reset(hw); Thanks!