]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA/hns: Fix accessing invalid dip_ctx during destroying QP
authorChengchang Tang <tangchengchang@huawei.com>
Fri, 20 Dec 2024 05:52:47 +0000 (13:52 +0800)
committerLeon Romanovsky <leon@kernel.org>
Mon, 23 Dec 2024 14:58:30 +0000 (09:58 -0500)
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>
drivers/infiniband/hw/hns/hns_roce_hw_v2.c

index 697b17cca02e71af8156771f15f98f109f65e6e9..6dddadb90e02600f4f8d6ba65ebc4b8611fc4063 100644 (file)
@@ -5619,6 +5619,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--;