diff options
Diffstat (limited to 'drivers/infiniband/hw/mlx5/cq.c')
-rw-r--r-- | drivers/infiniband/hw/mlx5/cq.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c index 62bb6b49dc1d..8ae4f896cb41 100644 --- a/drivers/infiniband/hw/mlx5/cq.c +++ b/drivers/infiniband/hw/mlx5/cq.c | |||
@@ -32,6 +32,7 @@ | |||
32 | 32 | ||
33 | #include <linux/kref.h> | 33 | #include <linux/kref.h> |
34 | #include <rdma/ib_umem.h> | 34 | #include <rdma/ib_umem.h> |
35 | #include <rdma/ib_user_verbs.h> | ||
35 | #include "mlx5_ib.h" | 36 | #include "mlx5_ib.h" |
36 | #include "user.h" | 37 | #include "user.h" |
37 | 38 | ||
@@ -602,14 +603,24 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata, | |||
602 | int *cqe_size, int *index, int *inlen) | 603 | int *cqe_size, int *index, int *inlen) |
603 | { | 604 | { |
604 | struct mlx5_ib_create_cq ucmd; | 605 | struct mlx5_ib_create_cq ucmd; |
606 | size_t ucmdlen; | ||
605 | int page_shift; | 607 | int page_shift; |
606 | int npages; | 608 | int npages; |
607 | int ncont; | 609 | int ncont; |
608 | int err; | 610 | int err; |
609 | 611 | ||
610 | if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) | 612 | ucmdlen = |
613 | (udata->inlen - sizeof(struct ib_uverbs_cmd_hdr) < | ||
614 | sizeof(ucmd)) ? (sizeof(ucmd) - | ||
615 | sizeof(ucmd.reserved)) : sizeof(ucmd); | ||
616 | |||
617 | if (ib_copy_from_udata(&ucmd, udata, ucmdlen)) | ||
611 | return -EFAULT; | 618 | return -EFAULT; |
612 | 619 | ||
620 | if (ucmdlen == sizeof(ucmd) && | ||
621 | ucmd.reserved != 0) | ||
622 | return -EINVAL; | ||
623 | |||
613 | if (ucmd.cqe_size != 64 && ucmd.cqe_size != 128) | 624 | if (ucmd.cqe_size != 64 && ucmd.cqe_size != 128) |
614 | return -EINVAL; | 625 | return -EINVAL; |
615 | 626 | ||