Skip to content

Commit a1b0e4e

Browse files
Michael Chandavem330
Michael Chan
authored andcommitted
bnxt_en: Improve RX consumer index validity check.
There is logic to check that the RX/TPA consumer index is the expected index to work around a hardware problem. However, the potentially bad consumer index is first used to index into an array to reference an entry. This can potentially crash if the bad consumer index is beyond legal range. Improve the logic to use the consumer index for dereferencing after the validity check and log an error message. Fixes: fa7e281 ("bnxt_en: Add workaround to detect bad opaque in rx completion (part 2)") Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a625204 commit a1b0e4e

File tree

1 file changed

+7
-3
lines changed
  • drivers/net/ethernet/broadcom/bnxt

1 file changed

+7
-3
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,8 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
11331133
tpa_info = &rxr->rx_tpa[agg_id];
11341134

11351135
if (unlikely(cons != rxr->rx_next_cons)) {
1136+
netdev_warn(bp->dev, "TPA cons %x != expected cons %x\n",
1137+
cons, rxr->rx_next_cons);
11361138
bnxt_sched_reset(bp, rxr);
11371139
return;
11381140
}
@@ -1585,15 +1587,17 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
15851587
}
15861588

15871589
cons = rxcmp->rx_cmp_opaque;
1588-
rx_buf = &rxr->rx_buf_ring[cons];
1589-
data = rx_buf->data;
1590-
data_ptr = rx_buf->data_ptr;
15911590
if (unlikely(cons != rxr->rx_next_cons)) {
15921591
int rc1 = bnxt_discard_rx(bp, cpr, raw_cons, rxcmp);
15931592

1593+
netdev_warn(bp->dev, "RX cons %x != expected cons %x\n",
1594+
cons, rxr->rx_next_cons);
15941595
bnxt_sched_reset(bp, rxr);
15951596
return rc1;
15961597
}
1598+
rx_buf = &rxr->rx_buf_ring[cons];
1599+
data = rx_buf->data;
1600+
data_ptr = rx_buf->data_ptr;
15971601
prefetch(data_ptr);
15981602

15991603
misc = le32_to_cpu(rxcmp->rx_cmp_misc_v1);

0 commit comments

Comments
 (0)