The userspace side on MW made a mistake and never actually used the udata driver structure that was defined so it always passes 0 length. Keep the kernel structure but this conversion has to permit 0 length as well.
Signed-off-by: Jason Gunthorpe <[email protected]> --- drivers/infiniband/hw/mlx5/mr.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index cbe34251e340b9..3ef467ac9e3d15 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -1774,16 +1774,13 @@ int mlx5_ib_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata) __u32 response_length; } resp = {}; - err = ib_copy_from_udata(&req, udata, min(udata->inlen, sizeof(req))); - if (err) - return err; + if (udata->inlen) { + err = ib_copy_validate_udata_in_cm(udata, req, reserved2, 0); + if (err) + return err; + } - if (req.comp_mask || req.reserved1 || req.reserved2) - return -EOPNOTSUPP; - - if (udata->inlen > sizeof(req) && - !ib_is_udata_cleared(udata, sizeof(req), - udata->inlen - sizeof(req))) + if (req.reserved1 || req.reserved2) return -EOPNOTSUPP; ndescs = req.num_klms ? roundup(req.num_klms, 4) : roundup(1, 4); -- 2.43.0
