netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Garzik <jeff@garzik.org>
To: Michael Chan <mchan@broadcom.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH 4/20][BNX2]: Fix race conditions when calling register_netdev().
Date: Wed, 02 May 2007 03:07:54 -0400	[thread overview]
Message-ID: <463838CA.6060002@garzik.org> (raw)
In-Reply-To: <1178068447.4820.40.camel@dell>

Michael Chan wrote:
> [BNX2]: Fix race conditions when calling register_netdev().
>     
> Hot-plug scripts can call bnx2_open() as soon as register_netdev() is
> called in bnx2_init_one().  We need to call pci_set_drvdata() and
> setup everything before calling register_netdev(). netif_carrier_off()
> also needs to be moved to bnx2_open() to avoid race conditions with
> the irq.
>     
> Signed-off-by: Michael Chan <mchan@broadcom.com>
> 
> diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
> index dba4088..971607c 100644
> --- a/drivers/net/bnx2.c
> +++ b/drivers/net/bnx2.c
> @@ -4350,6 +4350,8 @@ bnx2_open(struct net_device *dev)
>  	struct bnx2 *bp = netdev_priv(dev);
>  	int rc;
>  
> +	netif_carrier_off(dev);
> +
>  	bnx2_set_power_state(bp, PCI_D0);
>  	bnx2_disable_int(bp);
>  
> @@ -6195,6 +6197,18 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	dev->poll_controller = poll_bnx2;
>  #endif
>  
> +	pci_set_drvdata(pdev, dev);
> +
> +	memcpy(dev->dev_addr, bp->mac_addr, 6);
> +	memcpy(dev->perm_addr, bp->mac_addr, 6);
> +	bp->name = board_info[ent->driver_data].name;
> +
> +	dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
> +#ifdef BCM_VLAN
> +	dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
> +#endif
> +	dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
> +
>  	if ((rc = register_netdev(dev))) {
>  		dev_err(&pdev->dev, "Cannot register net device\n");
>  		if (bp->regview)
> @@ -6206,11 +6220,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		return rc;
>  	}
>  
> -	pci_set_drvdata(pdev, dev);
> -
> -	memcpy(dev->dev_addr, bp->mac_addr, 6);
> -	memcpy(dev->perm_addr, bp->mac_addr, 6);
> -	bp->name = board_info[ent->driver_data].name,

NAK.  Since you move the pci_set_drvdata() call, you must now add a call 
to pci_set_drvdata(pdev, NULL) on error.

ACK, once fixed.



  reply	other threads:[~2007-05-02  7:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-02  1:14 [PATCH 4/20][BNX2]: Fix race conditions when calling register_netdev() Michael Chan
2007-05-02  7:07 ` Jeff Garzik [this message]
2007-05-03  1:13   ` Michael Chan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=463838CA.6060002@garzik.org \
    --to=jeff@garzik.org \
    --cc=davem@davemloft.net \
    --cc=mchan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).