diff options
author | Michael Chan <mchan@broadcom.com> | 2006-12-17 20:07:29 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-18 00:59:20 -0500 |
commit | c49a1561ee4b663d2819b5bea3e4684eae217b19 (patch) | |
tree | 59909de4a5cba3bb84ee4b09fd793af46efc0f4f /drivers/net/tg3.c | |
parent | 24fcad6b3ca3bdbbb4614de3edc1ff16f594ba9a (diff) |
[TG3]: Fix race condition when calling register_netdev().
Hot-plug scripts can call tg3_open() as soon as register_netdev() is
called in tg3_init_one(). We need to call pci_set_drvdata() before
register_netdev(), and netif_carrier_off() needs to be moved to
tg3_open() to avoid race conditions.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index e47a9c1f35cb..501ea6da03cc 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -6981,6 +6981,8 @@ static int tg3_open(struct net_device *dev) | |||
6981 | struct tg3 *tp = netdev_priv(dev); | 6981 | struct tg3 *tp = netdev_priv(dev); |
6982 | int err; | 6982 | int err; |
6983 | 6983 | ||
6984 | netif_carrier_off(tp->dev); | ||
6985 | |||
6984 | tg3_full_lock(tp, 0); | 6986 | tg3_full_lock(tp, 0); |
6985 | 6987 | ||
6986 | err = tg3_set_power_state(tp, PCI_D0); | 6988 | err = tg3_set_power_state(tp, PCI_D0); |
@@ -11920,6 +11922,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
11920 | */ | 11922 | */ |
11921 | pci_save_state(tp->pdev); | 11923 | pci_save_state(tp->pdev); |
11922 | 11924 | ||
11925 | pci_set_drvdata(pdev, dev); | ||
11926 | |||
11923 | err = register_netdev(dev); | 11927 | err = register_netdev(dev); |
11924 | if (err) { | 11928 | if (err) { |
11925 | printk(KERN_ERR PFX "Cannot register net device, " | 11929 | printk(KERN_ERR PFX "Cannot register net device, " |
@@ -11927,8 +11931,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
11927 | goto err_out_iounmap; | 11931 | goto err_out_iounmap; |
11928 | } | 11932 | } |
11929 | 11933 | ||
11930 | pci_set_drvdata(pdev, dev); | ||
11931 | |||
11932 | printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (%s) %s Ethernet ", | 11934 | printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (%s) %s Ethernet ", |
11933 | dev->name, | 11935 | dev->name, |
11934 | tp->board_part_number, | 11936 | tp->board_part_number, |
@@ -11959,8 +11961,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, | |||
11959 | (pdev->dma_mask == DMA_32BIT_MASK) ? 32 : | 11961 | (pdev->dma_mask == DMA_32BIT_MASK) ? 32 : |
11960 | (((u64) pdev->dma_mask == DMA_40BIT_MASK) ? 40 : 64)); | 11962 | (((u64) pdev->dma_mask == DMA_40BIT_MASK) ? 40 : 64)); |
11961 | 11963 | ||
11962 | netif_carrier_off(tp->dev); | ||
11963 | |||
11964 | return 0; | 11964 | return 0; |
11965 | 11965 | ||
11966 | err_out_iounmap: | 11966 | err_out_iounmap: |