Skip to content

Commit

Permalink
[TG3]: Fix race condition when calling register_netdev().
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Chan authored and David S. Miller committed Dec 18, 2006
1 parent 24fcad6 commit c49a156
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/net/tg3.c
Original file line number Diff line number Diff line change
Expand Up @@ -6981,6 +6981,8 @@ static int tg3_open(struct net_device *dev)
struct tg3 *tp = netdev_priv(dev);
int err;

netif_carrier_off(tp->dev);

tg3_full_lock(tp, 0);

err = tg3_set_power_state(tp, PCI_D0);
Expand Down Expand Up @@ -11920,15 +11922,15 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
*/
pci_save_state(tp->pdev);

pci_set_drvdata(pdev, dev);

err = register_netdev(dev);
if (err) {
printk(KERN_ERR PFX "Cannot register net device, "
"aborting.\n");
goto err_out_iounmap;
}

pci_set_drvdata(pdev, dev);

printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (%s) %s Ethernet ",
dev->name,
tp->board_part_number,
Expand Down Expand Up @@ -11959,8 +11961,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
(pdev->dma_mask == DMA_32BIT_MASK) ? 32 :
(((u64) pdev->dma_mask == DMA_40BIT_MASK) ? 40 : 64));

netif_carrier_off(tp->dev);

return 0;

err_out_iounmap:
Expand Down

0 comments on commit c49a156

Please sign in to comment.