Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/mlx4: Use ib_copy_validate_udata_in() for QP

Move the validation of the udata to the same function that copies it.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>

authored by

Jason Gunthorpe and committed by
Leon Romanovsky
0453bf09 f8997870

+3 -22
+3 -22
drivers/infiniband/hw/mlx4/qp.c
··· 854 854 unsigned long flags; 855 855 int range_size; 856 856 struct mlx4_ib_create_wq wq; 857 - size_t copy_len; 858 857 int shift; 859 858 int n; 860 859 ··· 866 867 867 868 qp->state = IB_QPS_RESET; 868 869 869 - copy_len = min(sizeof(struct mlx4_ib_create_wq), udata->inlen); 870 - 871 - if (ib_copy_from_udata(&wq, udata, copy_len)) { 872 - err = -EFAULT; 870 + err = ib_copy_validate_udata_in(udata, wq, comp_mask); 871 + if (err) 873 872 goto err; 874 - } 875 873 876 874 if (wq.comp_mask || wq.reserved[0] || wq.reserved[1] || 877 875 wq.reserved[2]) { ··· 4108 4112 struct mlx4_dev *dev = to_mdev(pd->device)->dev; 4109 4113 struct ib_qp_init_attr ib_qp_init_attr = {}; 4110 4114 struct mlx4_ib_qp *qp; 4111 - struct mlx4_ib_create_wq ucmd; 4112 - int err, required_cmd_sz; 4115 + int err; 4113 4116 4114 4117 if (!udata) 4115 4118 return ERR_PTR(-EINVAL); 4116 - 4117 - required_cmd_sz = offsetof(typeof(ucmd), comp_mask) + 4118 - sizeof(ucmd.comp_mask); 4119 - if (udata->inlen < required_cmd_sz) { 4120 - pr_debug("invalid inlen\n"); 4121 - return ERR_PTR(-EINVAL); 4122 - } 4123 - 4124 - if (udata->inlen > sizeof(ucmd) && 4125 - !ib_is_udata_cleared(udata, sizeof(ucmd), 4126 - udata->inlen - sizeof(ucmd))) { 4127 - pr_debug("inlen is not supported\n"); 4128 - return ERR_PTR(-EOPNOTSUPP); 4129 - } 4130 4119 4131 4120 if (udata->outlen) 4132 4121 return ERR_PTR(-EOPNOTSUPP);