Skip to content

Commit 9d9d4ff

Browse files
oulijunjgunthorpe
authored andcommitted
RDMA/hns: Update the kernel header file of hns
The hns_roce_ib_create_srq_resp is used to interact with the user for data, this was open coded to use a u32 directly, instead use a properly sized structure. Fixes: c7bcb13 ("RDMA/hns: Add SRQ support for hip08 kernel mode") Signed-off-by: Lijun Ou <oulijun@huawei.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 951d01b commit 9d9d4ff

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

drivers/infiniband/hw/hns/hns_roce_srq.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
210210
struct ib_udata *udata)
211211
{
212212
struct hns_roce_dev *hr_dev = to_hr_dev(pd->device);
213+
struct hns_roce_ib_create_srq_resp resp = {};
213214
struct hns_roce_srq *srq;
214215
int srq_desc_size;
215216
int srq_buf_size;
@@ -378,16 +379,21 @@ struct ib_srq *hns_roce_create_srq(struct ib_pd *pd,
378379

379380
srq->event = hns_roce_ib_srq_event;
380381
srq->ibsrq.ext.xrc.srq_num = srq->srqn;
382+
resp.srqn = srq->srqn;
381383

382384
if (udata) {
383-
if (ib_copy_to_udata(udata, &srq->srqn, sizeof(__u32))) {
385+
if (ib_copy_to_udata(udata, &resp,
386+
min(udata->outlen, sizeof(resp)))) {
384387
ret = -EFAULT;
385-
goto err_wrid;
388+
goto err_srqc_alloc;
386389
}
387390
}
388391

389392
return &srq->ibsrq;
390393

394+
err_srqc_alloc:
395+
hns_roce_srq_free(hr_dev, srq);
396+
391397
err_wrid:
392398
kvfree(srq->wrid);
393399

include/uapi/rdma/hns-abi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ struct hns_roce_ib_create_srq {
5252
__aligned_u64 que_addr;
5353
};
5454

55+
struct hns_roce_ib_create_srq_resp {
56+
__u32 srqn;
57+
__u32 reserved;
58+
};
59+
5560
struct hns_roce_ib_create_qp {
5661
__aligned_u64 buf_addr;
5762
__aligned_u64 db_addr;

0 commit comments

Comments
 (0)