bnxt_en: Small misc. fixes.
Michael Chan
maintainercover bnxt_en: Small misc. fixes.
Fix a NULL pointer crash in open failure path, wrong arguments when printing error messages, and a DMA unmap bug in XDP shutdown path.
Michael Chan (1):
bnxt_en: Fix DMA unmapping of the RX buffers in XDP mode during
shutdown.
Sankar Patchineelam (2):
bnxt_en: Fix NULL pointer dereference in reopen failure path
bnxt_en: Correct the order of arguments to netdev_err() in
bnxt_set_tpa()
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 1/3 bnxt_en: Fix NULL pointer dereference in reopen failure path
From: Sankar Patchineelam <[email protected]>
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.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +13 -0
@@ -2455,6 +2455,18 @@ static int bnxt_init_one_rx_ring(struct bnxt *bp, int ring_nr)return 0 ; } +static void bnxt_init_cp_rings (struct bnxt *bp) +{ +int i; + +for (i =0 ; i < bp->cp_nr_rings; i++) { +struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring; +struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; + + ring->fw_ring_id =INVALID_HW_RING_ID ; + } +} +static int bnxt_init_rx_rings (struct bnxt *bp) {int i, rc =0 ;
@@ -5006,6 +5018,7 @@ static int bnxt_shutdown_nic(struct bnxt *bp, bool irq_re_init)static int bnxt_init_nic (struct bnxt *bp,bool irq_re_init) { +bnxt_init_cp_rings (bp);bnxt_init_rx_rings (bp);bnxt_init_tx_rings (bp);bnxt_init_ring_grps (bp, irq_re_init);
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 2/3 bnxt_en: Correct the order of arguments to netdev_err() in bnxt_set_tpa()
In reply to Michael ChanFrom: Sankar Patchineelam <[email protected]>
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -1
@@ -4744,7 +4744,7 @@ static int bnxt_set_tpa(struct bnxt *bp, bool set_tpa) rc =bnxt_hwrm_vnic_set_tpa (bp, i, tpa_flags);if (rc) {netdev_err (bp->dev,"hwrm vnic set tpa failure rc for vnic %d: %x\n" , - rc, i); + i, rc);return rc; } }
Signature · 1 line
1.8.3.1
Michael Chan
maintainerPATCH 3/3 bnxt_en: Fix DMA unmapping of the RX buffers in XDP mode during shutdown.
In reply to Michael ChanIn bnxt_free_rx_skbs(), which is called to free up all RX buffers during shutdown, we need to unmap the page if we are running in XDP mode.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +10 -5
@@ -1983,20 +1983,25 @@ static void bnxt_free_rx_skbs(struct bnxt *bp)for (j =0 ; j < max_idx; j++) {struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[j]; +dma_addr_t mapping = rx_buf->mapping;void *data = rx_buf->data;if (!data)continue ; -dma_unmap_single (&pdev->dev, rx_buf->mapping, - bp->rx_buf_use_size, bp->rx_dir); - rx_buf->data =NULL ; -if (BNXT_RX_PAGE_MODE (bp)) +if (BNXT_RX_PAGE_MODE (bp)) { + mapping -= bp->rx_dma_offset; +dma_unmap_page (&pdev->dev, mapping, +PAGE_SIZE , bp->rx_dir);__free_page (data); -else + }else { +dma_unmap_single (&pdev->dev, mapping, + bp->rx_buf_use_size, + bp->rx_dir);kfree (data); + } }for (j =0 ; j < max_agg_idx; j++) {
Signature · 1 line
1.8.3.1
David Miller
maintainerFrom: Michael Chan <[email protected]>
Date: Tue, 28 Mar 2017 19:47:28 -0400
Quoted 2 lines
Fix a NULL pointer crash in open failure path, wrong arguments when printing error messages, and a DMA unmap bug in XDP shutdown path.
Series applied.