Skip to content

Commit c8f9a7a

Browse files
jgunthorperleon
authored andcommitted
RDMA/mlx5: Use ib_copy_validate_udata_in() for SRQ
flags is the last member for mlx5_ib_create_srq, the uidx is a later extension. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
1 parent 3268330 commit c8f9a7a

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

  • drivers/infiniband/hw/mlx5

drivers/infiniband/hw/mlx5/srq.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,16 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
4848
struct mlx5_ib_create_srq ucmd = {};
4949
struct mlx5_ib_ucontext *ucontext = rdma_udata_to_drv_context(
5050
udata, struct mlx5_ib_ucontext, ibucontext);
51-
size_t ucmdlen;
5251
int err;
5352
u32 uidx = MLX5_IB_DEFAULT_UIDX;
5453

55-
ucmdlen = min(udata->inlen, sizeof(ucmd));
56-
57-
if (ib_copy_from_udata(&ucmd, udata, ucmdlen)) {
58-
mlx5_ib_dbg(dev, "failed copy udata\n");
59-
return -EFAULT;
60-
}
54+
err = ib_copy_validate_udata_in(udata, ucmd, flags);
55+
if (err)
56+
return err;
6157

6258
if (ucmd.reserved0 || ucmd.reserved1)
6359
return -EINVAL;
6460

65-
if (udata->inlen > sizeof(ucmd) &&
66-
!ib_is_udata_cleared(udata, sizeof(ucmd),
67-
udata->inlen - sizeof(ucmd)))
68-
return -EINVAL;
69-
7061
if (in->type != IB_SRQT_BASIC) {
7162
err = get_srq_user_index(ucontext, &ucmd, udata->inlen, &uidx);
7263
if (err)

0 commit comments

Comments
 (0)