diff options
author | Sankar Patchineelam <sankar.patchineelam@broadcom.com> | 2017-03-28 19:47:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-03-29 17:05:33 -0400 |
commit | 2247925f0942dc4e7c09b1cde45ca18461d94c5f (patch) | |
tree | c80b85f745a4ca6d83298f60ffe8ef6bbfb891b9 | |
parent | e91793bb615cf6cdd59c0b6749fe173687bb0947 (diff) |
bnxt_en: Fix NULL pointer dereference in reopen failure path
Net device reset can fail when the h/w or f/w is in a bad state.
Subsequent netdevice open fails in bnxt_hwrm_stat_ctx_alloc().
The cleanup invokes bnxt_hwrm_resource_free() which inturn
calls bnxt_disable_int(). In this routine, the code segment
if (ring->fw_ring_id != INVALID_HW_RING_ID)
BNXT_CP_DB(cpr->cp_doorbell, cpr->cp_raw_cons);
results in NULL pointer dereference as cpr->cp_doorbell is not yet
initialized, and fw_ring_id is zero.
The fix is to initialize cpr fw_ring_id to INVALID_HW_RING_ID before
bnxt_init_chip() is invoked.
Signed-off-by: Sankar Patchineelam <sankar.patchineelam@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 32de4589d16a..7ee772483f26 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c | |||
@@ -2455,6 +2455,18 @@ static int bnxt_init_one_rx_ring(struct bnxt *bp, int ring_nr) | |||
2455 | return 0; | 2455 | return 0; |
2456 | } | 2456 | } |
2457 | 2457 | ||
2458 | static void bnxt_init_cp_rings(struct bnxt *bp) | ||
2459 | { | ||
2460 | int i; | ||
2461 | |||
2462 | for (i = 0; i < bp->cp_nr_rings; i++) { | ||
2463 | struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring; | ||
2464 | struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; | ||
2465 | |||
2466 | ring->fw_ring_id = INVALID_HW_RING_ID; | ||
2467 | } | ||
2468 | } | ||
2469 | |||
2458 | static int bnxt_init_rx_rings(struct bnxt *bp) | 2470 | static int bnxt_init_rx_rings(struct bnxt *bp) |
2459 | { | 2471 | { |
2460 | int i, rc = 0; | 2472 | int i, rc = 0; |
@@ -5006,6 +5018,7 @@ static int bnxt_shutdown_nic(struct bnxt *bp, bool irq_re_init) | |||
5006 | 5018 | ||
5007 | static int bnxt_init_nic(struct bnxt *bp, bool irq_re_init) | 5019 | static int bnxt_init_nic(struct bnxt *bp, bool irq_re_init) |
5008 | { | 5020 | { |
5021 | bnxt_init_cp_rings(bp); | ||
5009 | bnxt_init_rx_rings(bp); | 5022 | bnxt_init_rx_rings(bp); |
5010 | bnxt_init_tx_rings(bp); | 5023 | bnxt_init_tx_rings(bp); |
5011 | bnxt_init_ring_grps(bp, irq_re_init); | 5024 | bnxt_init_ring_grps(bp, irq_re_init); |