[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221017142652.13906-1-n.petrova@fintech.ru>
Date: Mon, 17 Oct 2022 17:26:52 +0300
From: Natalia Petrova <n.petrova@...tech.ru>
To: Dennis Dalessandro <dennis.dalessandro@...nelisnetworks.com>,
"Jason Gunthorpe" <jgg@...pe.ca>, Leon Romanovsky <leon@...nel.org>
CC: Natalia Petrova <n.petrova@...tech.ru>,
<linux-rdma@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<ldv-project@...uxtesting.org>,
"Alexey Khoroshilov" <khoroshilov@...ras.ru>
Subject: [PATCH] rdmavt: avoid NULL pointer dereference in rvt_qp_exit()
rvt_qp_exit() checks 'rdi->qp_dev' for NULL, but the pointer is
dereferenced before that in rvt_free_all_qps().
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: f92e48718889 ("IB/rdmavt: Reset all QPs when the device is shut
down")
Signed-off-by: Natalia Petrova <n.petrova@...tech.ru>
Signed-off-by: Alexey Khoroshilov <khoroshilov@...ras.ru>
---
drivers/infiniband/sw/rdmavt/qp.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
index 3acab569fbb9..06e755975f61 100644
--- a/drivers/infiniband/sw/rdmavt/qp.c
+++ b/drivers/infiniband/sw/rdmavt/qp.c
@@ -459,13 +459,16 @@ static unsigned rvt_free_all_qps(struct rvt_dev_info *rdi)
*/
void rvt_qp_exit(struct rvt_dev_info *rdi)
{
- u32 qps_inuse = rvt_free_all_qps(rdi);
+ u32 qps_inuse = 0;
+
+ if (!rdi->qp_dev)
+ return;
+
+ qps_inuse = rvt_free_all_qps(rdi);
if (qps_inuse)
rvt_pr_err(rdi, "QP memory leak! %u still in use\n",
qps_inuse);
- if (!rdi->qp_dev)
- return;
kfree(rdi->qp_dev->qp_table);
free_qpn_table(&rdi->qp_dev->qpn_table);
--
2.34.1
Powered by blists - more mailing lists