Commit c1dfc011 authored by Dan Carpenter's avatar Dan Carpenter Committed by Jason Gunthorpe

RDMA/bnxt_re: Fix a bunch of off by one bugs in qplib_fp.c

The srq->swq[] is allocated in bnxt_qplib_create_srq().  It has
srq->hwq.max_elements elements so these tests should be > instead of >=
or we might go beyond the end of the array.

Fixes: 1ac5a404 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarSelvin Xavier <selvin.xavier@broadcom.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 474e5a86
...@@ -2354,7 +2354,7 @@ static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq, ...@@ -2354,7 +2354,7 @@ static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq,
srq = qp->srq; srq = qp->srq;
if (!srq) if (!srq)
return -EINVAL; return -EINVAL;
if (wr_id_idx > srq->hwq.max_elements) { if (wr_id_idx >= srq->hwq.max_elements) {
dev_err(&cq->hwq.pdev->dev, dev_err(&cq->hwq.pdev->dev,
"QPLIB: FP: CQ Process RC "); "QPLIB: FP: CQ Process RC ");
dev_err(&cq->hwq.pdev->dev, dev_err(&cq->hwq.pdev->dev,
...@@ -2369,7 +2369,7 @@ static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq, ...@@ -2369,7 +2369,7 @@ static int bnxt_qplib_cq_process_res_rc(struct bnxt_qplib_cq *cq,
*pcqe = cqe; *pcqe = cqe;
} else { } else {
rq = &qp->rq; rq = &qp->rq;
if (wr_id_idx > rq->hwq.max_elements) { if (wr_id_idx >= rq->hwq.max_elements) {
dev_err(&cq->hwq.pdev->dev, dev_err(&cq->hwq.pdev->dev,
"QPLIB: FP: CQ Process RC "); "QPLIB: FP: CQ Process RC ");
dev_err(&cq->hwq.pdev->dev, dev_err(&cq->hwq.pdev->dev,
...@@ -2437,7 +2437,7 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq, ...@@ -2437,7 +2437,7 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq,
if (!srq) if (!srq)
return -EINVAL; return -EINVAL;
if (wr_id_idx > srq->hwq.max_elements) { if (wr_id_idx >= srq->hwq.max_elements) {
dev_err(&cq->hwq.pdev->dev, dev_err(&cq->hwq.pdev->dev,
"QPLIB: FP: CQ Process UD "); "QPLIB: FP: CQ Process UD ");
dev_err(&cq->hwq.pdev->dev, dev_err(&cq->hwq.pdev->dev,
...@@ -2452,7 +2452,7 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq, ...@@ -2452,7 +2452,7 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq,
*pcqe = cqe; *pcqe = cqe;
} else { } else {
rq = &qp->rq; rq = &qp->rq;
if (wr_id_idx > rq->hwq.max_elements) { if (wr_id_idx >= rq->hwq.max_elements) {
dev_err(&cq->hwq.pdev->dev, dev_err(&cq->hwq.pdev->dev,
"QPLIB: FP: CQ Process UD "); "QPLIB: FP: CQ Process UD ");
dev_err(&cq->hwq.pdev->dev, dev_err(&cq->hwq.pdev->dev,
...@@ -2546,7 +2546,7 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq, ...@@ -2546,7 +2546,7 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq,
"QPLIB: FP: SRQ used but not defined??"); "QPLIB: FP: SRQ used but not defined??");
return -EINVAL; return -EINVAL;
} }
if (wr_id_idx > srq->hwq.max_elements) { if (wr_id_idx >= srq->hwq.max_elements) {
dev_err(&cq->hwq.pdev->dev, dev_err(&cq->hwq.pdev->dev,
"QPLIB: FP: CQ Process Raw/QP1 "); "QPLIB: FP: CQ Process Raw/QP1 ");
dev_err(&cq->hwq.pdev->dev, dev_err(&cq->hwq.pdev->dev,
...@@ -2561,7 +2561,7 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq, ...@@ -2561,7 +2561,7 @@ static int bnxt_qplib_cq_process_res_raweth_qp1(struct bnxt_qplib_cq *cq,
*pcqe = cqe; *pcqe = cqe;
} else { } else {
rq = &qp->rq; rq = &qp->rq;
if (wr_id_idx > rq->hwq.max_elements) { if (wr_id_idx >= rq->hwq.max_elements) {
dev_err(&cq->hwq.pdev->dev, dev_err(&cq->hwq.pdev->dev,
"QPLIB: FP: CQ Process Raw/QP1 RQ wr_id "); "QPLIB: FP: CQ Process Raw/QP1 RQ wr_id ");
dev_err(&cq->hwq.pdev->dev, dev_err(&cq->hwq.pdev->dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment