diff mbox

RDMA/bnxt_re: Fix a couple off by one bugs

Message ID 20180704095711.v3mjb3qkbgo6iw2r@kili.mountain (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show

Commit Message

Dan Carpenter July 4, 2018, 9:57 a.m. UTC
The sgid_tbl->tbl[] array is allocated in bnxt_qplib_alloc_sgid_tbl().
It has sgid_tbl->max elements.  So the > should be >= to prevent
accessing one element beyond the end of the array.

Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Selvin Xavier July 4, 2018, 10:39 a.m. UTC | #1
On Wed, Jul 4, 2018 at 3:27 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> The sgid_tbl->tbl[] array is allocated in bnxt_qplib_alloc_sgid_tbl().
> It has sgid_tbl->max elements.  So the > should be >= to prevent
> accessing one element beyond the end of the array.
>
> Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>

Acked-by: Selvin Xavier <selvin.xavier@broadcom.com>

Thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jason Gunthorpe July 4, 2018, 6:07 p.m. UTC | #2
On Wed, Jul 04, 2018 at 12:57:11PM +0300, Dan Carpenter wrote:
> The sgid_tbl->tbl[] array is allocated in bnxt_qplib_alloc_sgid_tbl().
> It has sgid_tbl->max elements.  So the > should be >= to prevent
> accessing one element beyond the end of the array.
> 
> Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Acked-by: Selvin Xavier <selvin.xavier@broadcom.com>

Applied to for-next

Thanks,
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/hw/bnxt_re/qplib_sp.c b/drivers/infiniband/hw/bnxt_re/qplib_sp.c
index 2f3f32eaa1d5..4097f3fa25c5 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_sp.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_sp.c
@@ -197,7 +197,7 @@  int bnxt_qplib_get_sgid(struct bnxt_qplib_res *res,
 			struct bnxt_qplib_sgid_tbl *sgid_tbl, int index,
 			struct bnxt_qplib_gid *gid)
 {
-	if (index > sgid_tbl->max) {
+	if (index >= sgid_tbl->max) {
 		dev_err(&res->pdev->dev,
 			"QPLIB: Index %d exceeded SGID table max (%d)",
 			index, sgid_tbl->max);
@@ -402,7 +402,7 @@  int bnxt_qplib_get_pkey(struct bnxt_qplib_res *res,
 		*pkey = 0xFFFF;
 		return 0;
 	}
-	if (index > pkey_tbl->max) {
+	if (index >= pkey_tbl->max) {
 		dev_err(&res->pdev->dev,
 			"QPLIB: Index %d exceeded PKEY table max (%d)",
 			index, pkey_tbl->max);