提交 84eacd11 编写于 作者: W wangsirong 提交者: Xie XiuQi

RDMA/hns: Add a comparision of udata and resp data

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

If length of udata is less than resp data, it should use the minimum value

Feature or Bugfix:Bugfix
Signed-off-by: Nwangsirong <wangsirong@huawei.com>
Reviewed-by: Nliyangyang20 <liyangyang20@huawei.com>
Reviewed-by: Nhdd.huang <hdd.huang@huawei.com>
Reviewed-by: Nwangxi <wangxi11@huawei.com>
Reviewed-by: Nliuyixian <liuyixian@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 e166bec9
...@@ -505,7 +505,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev, ...@@ -505,7 +505,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
if (context) { if (context) {
resp.cqn = hr_cq->cqn; resp.cqn = hr_cq->cqn;
ret = ib_copy_to_udata(udata, &resp, sizeof(resp)); ret = ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp)));
if (ret) if (ret)
goto err_cqc; goto err_cqc;
} }
......
...@@ -556,7 +556,7 @@ static struct ib_ucontext *hns_roce_alloc_ucontext(struct ib_device *ib_dev, ...@@ -556,7 +556,7 @@ static struct ib_ucontext *hns_roce_alloc_ucontext(struct ib_device *ib_dev,
mutex_init(&context->page_mutex); mutex_init(&context->page_mutex);
} }
ret = ib_copy_to_udata(udata, &resp, sizeof(resp)); ret = ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp)));
if (ret) if (ret)
goto error_fail_copy_to_udata; goto error_fail_copy_to_udata;
......
...@@ -988,8 +988,8 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev, ...@@ -988,8 +988,8 @@ static int hns_roce_create_qp_common(struct hns_roce_dev *hr_dev,
else else
hr_qp->doorbell_qpn = (u32)(hr_qp->qpn); hr_qp->doorbell_qpn = (u32)(hr_qp->qpn);
if (ib_pd->uobject && (udata->outlen >= sizeof(resp))) { if (ib_pd->uobject) {
ret = ib_copy_to_udata(udata, &resp, sizeof(resp)); ret = ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp)));
if (ret) if (ret)
goto err_qp; goto err_qp;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册