RDMA/bnxt_re: Fix the qp table indexing
authorSelvin Xavier <selvin.xavier@broadcom.com>
Mon, 24 Aug 2020 18:14:33 +0000 (11:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Sep 2020 11:55:26 +0000 (13:55 +0200)
commit1e608f9308aa30b2e42ddd06b5e9d8e13b97758d
treeb5df1417be2077edc5dfc1e8d7f8e34000cabb20
parent6bcab9b51bab1a36cdf7bb3e5c814cabe8325d8e
RDMA/bnxt_re: Fix the qp table indexing

[ Upstream commit 84cf229f4001c1216afc3e4c7f05e1620a0dd4bc ]

qp->id can be a value outside the max number of qp. Indexing the qp table
with the id can cause out of bounds crash. So changing the qp table
indexing by (qp->id % max_qp -1).

Allocating one extra entry for QP1. Some adapters create one more than the
max_qp requested to accommodate QP1.  If the qp->id is 1, store the
inforamtion in the last entry of the qp table.

Fixes: f218d67ef004 ("RDMA/bnxt_re: Allow posting when QPs are in error")
Link: https://lore.kernel.org/r/1598292876-26529-4-git-send-email-selvin.xavier@broadcom.com
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/bnxt_re/qplib_fp.c
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c
drivers/infiniband/hw/bnxt_re/qplib_rcfw.h