bnxt_en: Improve RX consumer index validity check.
[ Upstream commit a1b0e4e684e9c300b9e759b46cb7a0147e61ddff ] 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: fa7e28127a5a ("bnxt_en: Add workaround to detect bad opaque in rx completion (part 2)") Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ebd153c683
commit
8e302e8e10
@ -959,6 +959,8 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
|
||||
tpa_info = &rxr->rx_tpa[agg_id];
|
||||
|
||||
if (unlikely(cons != rxr->rx_next_cons)) {
|
||||
netdev_warn(bp->dev, "TPA cons %x != expected cons %x\n",
|
||||
cons, rxr->rx_next_cons);
|
||||
bnxt_sched_reset(bp, rxr);
|
||||
return;
|
||||
}
|
||||
@ -1377,14 +1379,16 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_napi *bnapi, u32 *raw_cons,
|
||||
}
|
||||
|
||||
cons = rxcmp->rx_cmp_opaque;
|
||||
rx_buf = &rxr->rx_buf_ring[cons];
|
||||
data = rx_buf->data;
|
||||
if (unlikely(cons != rxr->rx_next_cons)) {
|
||||
int rc1 = bnxt_discard_rx(bp, bnapi, raw_cons, rxcmp);
|
||||
|
||||
netdev_warn(bp->dev, "RX cons %x != expected cons %x\n",
|
||||
cons, rxr->rx_next_cons);
|
||||
bnxt_sched_reset(bp, rxr);
|
||||
return rc1;
|
||||
}
|
||||
rx_buf = &rxr->rx_buf_ring[cons];
|
||||
data = rx_buf->data;
|
||||
prefetch(data);
|
||||
|
||||
agg_bufs = (le32_to_cpu(rxcmp->rx_cmp_misc_v1) & RX_CMP_AGG_BUFS) >>
|
||||
|
Loading…
x
Reference in New Issue
Block a user