RDMA/bnxt_re: Fix driver crash on unaligned PSN entry address
authorNaresh Kumar PBS <nareshkumar.pbs@broadcom.com>
Mon, 24 Aug 2020 18:14:36 +0000 (11:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Sep 2020 11:55:27 +0000 (13:55 +0200)
commitf51174da6e5137736e25e36946671ab885b39450
tree46e0d6adb5f2a51a5a1daba946339e2fb4525a35
parentd71b3a81c0acf91e2932bd2b2eaaf3dd770f2cb7
RDMA/bnxt_re: Fix driver crash on unaligned PSN entry address

[ Upstream commit 934d0ac9a64d21523e3ad03ea4098da7826bc788 ]

When computing the first psn entry, driver checks for page alignment. If
this address is not page aligned,it attempts to compute the offset in that
page for later use by using ALIGN macro. ALIGN macro does not return
offset bytes but the requested aligned address and hence cannot be used
directly to store as offset.  Since driver was using the address itself
instead of offset, it resulted in invalid address when filling the psn
buffer.

Fixed driver to use PAGE_MASK macro to calculate the offset.

Fixes: fddcbbb02af4 ("RDMA/bnxt_re: Simplify obtaining queue entry from hw ring")
Link: https://lore.kernel.org/r/1598292876-26529-7-git-send-email-selvin.xavier@broadcom.com
Signed-off-by: Naresh Kumar PBS <nareshkumar.pbs@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