aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2.c
diff options
context:
space:
mode:
authorBenjamin Li <benli@broadcom.com>2010-03-23 09:13:11 -0400
committerDavid S. Miller <davem@davemloft.net>2010-03-24 02:19:55 -0400
commit4327ba435a56ada13eedf3eb332e583c7a0586a9 (patch)
tree87332475d3fb1a6721659d9692730ec693caeb5a /drivers/net/bnx2.c
parent4881a4f89a95cc5fef6d32953954bcc3443eefd5 (diff)
bnx2: Fix netpoll crash.
The bnx2 driver calls netif_napi_add() for all the NAPI structs during ->probe() time but not all of them will be used if we're not in MSI-X mode. This creates a problem for netpoll since it will poll all the NAPI structs in the dev_list whether or not they are scheduled, resulting in a crash when we access structure fields not initialized for that vector. We fix it by moving the netif_napi_add() call to ->open() after the number of IRQ vectors has been determined. Signed-off-by: Benjamin Li <benli@broadcom.com> Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r--drivers/net/bnx2.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 381887ba677c..417de1cb2d46 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -246,6 +246,8 @@ static const struct flash_spec flash_5709 = {
246 246
247MODULE_DEVICE_TABLE(pci, bnx2_pci_tbl); 247MODULE_DEVICE_TABLE(pci, bnx2_pci_tbl);
248 248
249static void bnx2_init_napi(struct bnx2 *bp);
250
249static inline u32 bnx2_tx_avail(struct bnx2 *bp, struct bnx2_tx_ring_info *txr) 251static inline u32 bnx2_tx_avail(struct bnx2 *bp, struct bnx2_tx_ring_info *txr)
250{ 252{
251 u32 diff; 253 u32 diff;
@@ -6197,6 +6199,7 @@ bnx2_open(struct net_device *dev)
6197 bnx2_disable_int(bp); 6199 bnx2_disable_int(bp);
6198 6200
6199 bnx2_setup_int_mode(bp, disable_msi); 6201 bnx2_setup_int_mode(bp, disable_msi);
6202 bnx2_init_napi(bp);
6200 bnx2_napi_enable(bp); 6203 bnx2_napi_enable(bp);
6201 rc = bnx2_alloc_mem(bp); 6204 rc = bnx2_alloc_mem(bp);
6202 if (rc) 6205 if (rc)
@@ -8207,7 +8210,7 @@ bnx2_init_napi(struct bnx2 *bp)
8207{ 8210{
8208 int i; 8211 int i;
8209 8212
8210 for (i = 0; i < BNX2_MAX_MSIX_VEC; i++) { 8213 for (i = 0; i < bp->irq_nvecs; i++) {
8211 struct bnx2_napi *bnapi = &bp->bnx2_napi[i]; 8214 struct bnx2_napi *bnapi = &bp->bnx2_napi[i];
8212 int (*poll)(struct napi_struct *, int); 8215 int (*poll)(struct napi_struct *, int);
8213 8216
@@ -8276,7 +8279,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8276 dev->ethtool_ops = &bnx2_ethtool_ops; 8279 dev->ethtool_ops = &bnx2_ethtool_ops;
8277 8280
8278 bp = netdev_priv(dev); 8281 bp = netdev_priv(dev);
8279 bnx2_init_napi(bp);
8280 8282
8281 pci_set_drvdata(pdev, dev); 8283 pci_set_drvdata(pdev, dev);
8282 8284