From: Junxian Huang huangjunxian6@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9SI44
---------------------------------------------------------------------- Set NULL after mtr_node is freed.
This patch should be merged with the fixed one.
Fixes: 431c875e4b02 ("RDMA/hns: Fix simultaneous reset and resource deregistration") Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com Signed-off-by: Guofeng Yue yueguofeng@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_cq.c | 2 ++ drivers/infiniband/hw/hns/hns_roce_mr.c | 2 ++ drivers/infiniband/hw/hns/hns_roce_qp.c | 3 +++ drivers/infiniband/hw/hns/hns_roce_srq.c | 4 ++++ 4 files changed, 11 insertions(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_cq.c b/drivers/infiniband/hw/hns/hns_roce_cq.c index 695be916c91d..e26926622f23 100644 --- a/drivers/infiniband/hw/hns/hns_roce_cq.c +++ b/drivers/infiniband/hw/hns/hns_roce_cq.c @@ -224,6 +224,7 @@ static int alloc_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq, if (ret) { ibdev_err(ibdev, "Failed to alloc CQ mtr, ret = %d\n", ret); kvfree(hr_cq->mtr_node); + hr_cq->mtr_node = NULL; }
return ret; @@ -236,6 +237,7 @@ static void free_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq) } else { hns_roce_mtr_destroy(hr_dev, &hr_cq->mtr); kvfree(hr_cq->mtr_node); + hr_cq->mtr_node = NULL; } }
diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c index 5af4e365afa5..3c36836dcf49 100644 --- a/drivers/infiniband/hw/hns/hns_roce_mr.c +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c @@ -122,6 +122,7 @@ static int alloc_mr_pbl(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr, if (err) { ibdev_err(ibdev, "failed to alloc pbl mtr, ret = %d.\n", err); kvfree(mr->mtr_node); + mr->mtr_node = NULL; return err; }
@@ -138,6 +139,7 @@ static void free_mr_pbl(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr) } else { hns_roce_mtr_destroy(hr_dev, &mr->pbl_mtr); kvfree(mr->mtr_node); + mr->mtr_node = NULL; } }
diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c index 4989828b5bad..bb0460e7db95 100644 --- a/drivers/infiniband/hw/hns/hns_roce_qp.c +++ b/drivers/infiniband/hw/hns/hns_roce_qp.c @@ -798,6 +798,7 @@ static int alloc_wqe_buf(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp, ibdev_err(ibdev, "failed to enable DCA, ret = %d.\n", ret); kvfree(hr_qp->mtr_node); + hr_qp->mtr_node = NULL; return ret; }
@@ -822,6 +823,7 @@ static int alloc_wqe_buf(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp, if (dca_en) hns_roce_disable_dca(hr_dev, hr_qp, udata); kvfree(hr_qp->mtr_node); + hr_qp->mtr_node = NULL; }
return ret; @@ -835,6 +837,7 @@ static void free_wqe_buf(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp, } else { hns_roce_mtr_destroy(hr_dev, &hr_qp->mtr); kvfree(hr_qp->mtr_node); + hr_qp->mtr_node = NULL; }
if (hr_qp->en_flags & HNS_ROCE_QP_CAP_DYNAMIC_CTX_ATTACH) diff --git a/drivers/infiniband/hw/hns/hns_roce_srq.c b/drivers/infiniband/hw/hns/hns_roce_srq.c index 1e57395f1148..cf7b0d51683a 100644 --- a/drivers/infiniband/hw/hns/hns_roce_srq.c +++ b/drivers/infiniband/hw/hns/hns_roce_srq.c @@ -222,6 +222,7 @@ static int alloc_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq, hns_roce_mtr_destroy(hr_dev, &idx_que->mtr); err_kvmalloc: kvfree(idx_que->mtr_node); + idx_que->mtr_node = NULL;
return ret; } @@ -237,6 +238,7 @@ static void free_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq) } else { hns_roce_mtr_destroy(hr_dev, &idx_que->mtr); kvfree(idx_que->mtr_node); + idx_que->mtr_node = NULL; } }
@@ -269,6 +271,7 @@ static int alloc_srq_wqe_buf(struct hns_roce_dev *hr_dev, ibdev_err(ibdev, "failed to alloc SRQ buf mtr, ret = %d.\n", ret); kvfree(srq->mtr_node); + srq->mtr_node = NULL; }
return ret; @@ -282,6 +285,7 @@ static void free_srq_wqe_buf(struct hns_roce_dev *hr_dev, } else { hns_roce_mtr_destroy(hr_dev, &srq->buf_mtr); kvfree(srq->mtr_node); + srq->mtr_node = NULL; } }