From ebf96e2ee3866ba2b030e28c1dec10e6bd4417ef Mon Sep 17 00:00:00 2001 From: Yangyang Li Date: Wed, 17 Jul 2019 17:17:27 +0800 Subject: [PATCH] RDMA/hns: Completely release qp resources when hw err driver inclusion category: bugfix bugzilla: NA CVE: NA Even if no response from hardware, make sure that qp related resources are completely released. Feature or Bugfix:Bugfix Signed-off-by: Yangyang Li Signed-off-by: liyangyang (M) Reviewed-by: liuyixian Reviewed-by: Yang Yingliang Signed-off-by: Yang Yingliang --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 6b433b453490..c679be7c72f3 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -5143,18 +5143,16 @@ static int hns_roce_v2_destroy_qp_common(struct hns_roce_dev *hr_dev, { struct hns_roce_cq *send_cq, *recv_cq; struct device *dev = hr_dev->dev; - int ret; + int ret = 0; if (hr_qp->ibqp.qp_type == IB_QPT_RC && hr_qp->state != IB_QPS_RESET) { /* Modify qp to reset before destroying qp */ ret = hns_roce_v2_modify_qp(&hr_qp->ibqp, NULL, 0, hr_qp->state, IB_QPS_RESET); - if (ret) { + if (ret) dev_err(dev, "modify QP %06lx to Reset failed, ret = %d.\n", hr_qp->qpn, ret); - return ret; - } } hns_roce_get_cqs(&hr_qp->ibqp, &send_cq, &recv_cq); @@ -5209,7 +5207,7 @@ static int hns_roce_v2_destroy_qp_common(struct hns_roce_dev *hr_dev, kfree(hr_qp->rq_inl_buf.wqe_list); } - return 0; + return ret; } static int hns_roce_v2_destroy_qp(struct ib_qp *ibqp) @@ -5224,18 +5222,16 @@ static int hns_roce_v2_destroy_qp(struct ib_qp *ibqp) hns_roce_inc_rdma_hw_stats(ibqp->device, HW_STATS_QP_DEALLOC); ret = hns_roce_v2_destroy_qp_common(hr_dev, hr_qp, !!ibqp->pd->uobject); - if (ret) { + if (ret) dev_err(hr_dev->dev, "Destroy qp 0x%06lx failed(%d)\n", hr_qp->qpn, ret); - return ret; - } if (hr_qp->ibqp.qp_type == IB_QPT_GSI) kfree(hr_to_hr_sqp(hr_qp)); else kfree(hr_qp); - return 0; + return ret; } static int hns_roce_v2_qp_flow_control_init(struct hns_roce_dev *hr_dev, -- GitLab