Commit 76827087 authored by Lijun Ou's avatar Lijun Ou Committed by Doug Ledford
Browse files

RDMA/hns: Bugfix for creating qp attached to srq



When create a qp and attached to srq, rq will no longer be used
and the members of rq will be set zero. As a result, the wrid
of rq will not be allocated and used.

Fixes: 926a01dc ("RDMA/hns: Add QP operations support for hip08 SoC")
Signed-off-by: default avatarLijun Ou <oulijun@huawei.com>
Link: https://lore.kernel.org/r/1565343666-73193-3-git-send-email-oulijun@huawei.com


Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 0e1aa6f0
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -854,11 +854,18 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,

		hr_qp->sq.wrid = kcalloc(hr_qp->sq.wqe_cnt, sizeof(u64),
					 GFP_KERNEL);
		if (ZERO_OR_NULL_PTR(hr_qp->sq.wrid)) {
			ret = -ENOMEM;
			goto err_get_bufs;
		}

		if (hr_qp->rq.wqe_cnt) {
			hr_qp->rq.wrid = kcalloc(hr_qp->rq.wqe_cnt, sizeof(u64),
						 GFP_KERNEL);
		if (!hr_qp->sq.wrid || !hr_qp->rq.wrid) {
			if (ZERO_OR_NULL_PTR(hr_qp->rq.wrid)) {
				ret = -ENOMEM;
			goto err_wrid;
				goto err_sq_wrid;
			}
		}
	}

@@ -944,7 +951,7 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
		    hns_roce_qp_has_rq(init_attr))
			hns_roce_db_unmap_user(uctx, &hr_qp->rdb);
	} else {
		kfree(hr_qp->sq.wrid);
		if (hr_qp->rq.wqe_cnt)
			kfree(hr_qp->rq.wrid);
	}

@@ -956,6 +963,10 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
		    hns_roce_qp_has_sq(init_attr))
			hns_roce_db_unmap_user(uctx, &hr_qp->sdb);

err_sq_wrid:
	if (!udata)
		kfree(hr_qp->sq.wrid);

err_get_bufs:
	hns_roce_free_buf_list(buf_list, hr_qp->region_cnt);