RDMA/hns: Fix accessing invalid dip_ctx during destroying QP

BugLink: https://bugs.launchpad.net/bugs/2101915

[ Upstream commit 0572eccf239ce4bd89bd531767ec5ab20e249290 ]

If it fails to modify QP to RTR, dip_ctx will not be attached. And
during detroying QP, the invalid dip_ctx pointer will be accessed.

Fixes: faa62440a577 ("RDMA/hns: Fix different dgids mapping to the same dip_idx")
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Link: https://patch.msgid.link/20241220055249.146943-3-huangjunxian6@hisilicon.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit a448c775f0aec6cfbee4bda561447c707153504a linux-6.12.y)
[koichiroden: follow-up fix from v6.12.9]
Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
This commit is contained in:
Chengchang Tang
2025-03-11 08:51:19 +09:00
committed by Stefan Bader
parent 7537f3c1e0
commit 943dd5941e
@@ -5559,6 +5559,9 @@ static void put_dip_ctx_idx(struct hns_roce_dev *hr_dev,
{
struct hns_roce_dip *hr_dip = hr_qp->dip;
if (!hr_dip)
return;
xa_lock(&hr_dev->qp_table.dip_xa);
hr_dip->qp_cnt--;