diff options
author | Jason Gunthorpe <jgg@nvidia.com> | 2020-11-30 08:58:35 +0100 |
---|---|---|
committer | Jason Gunthorpe <jgg@nvidia.com> | 2020-12-07 19:06:22 +0100 |
commit | b9653b31d7767b7dccc8b24b660301be90449036 (patch) | |
tree | 678c813c850aab69d2ce8c399879b0d11588fcbf /drivers/infiniband | |
parent | RDMA/efa: Use dma_set_mask_and_coherent() to simplify code (diff) | |
download | linux-b9653b31d7767b7dccc8b24b660301be90449036.tar.xz linux-b9653b31d7767b7dccc8b24b660301be90449036.zip |
RDMA/uverbs: Tidy input validation of ib_uverbs_rereg_mr()
Unknown flags should be EOPNOTSUPP, only zero flags is EINVAL. Flags is
actually the rereg action to perform.
The checking of the start/hca_va/etc is also redundant and ib_umem_get()
does these checks and returns proper error codes.
Fixes: 7e6edb9b2e0b ("IB/core: Add user MR re-registration support")
Link: https://lore.kernel.org/r/20201130075839.278575-2-leon@kernel.org
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/uverbs_cmd.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 402d0b8bf58e..143a0e33fe52 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -783,13 +783,15 @@ static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs) if (ret) return ret; - if (cmd.flags & ~IB_MR_REREG_SUPPORTED || !cmd.flags) + if (!cmd.flags) return -EINVAL; + if (cmd.flags & ~IB_MR_REREG_SUPPORTED) + return -EOPNOTSUPP; + if ((cmd.flags & IB_MR_REREG_TRANS) && - (!cmd.start || !cmd.hca_va || 0 >= cmd.length || - (cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK))) - return -EINVAL; + (cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK)) + return -EINVAL; uobj = uobj_get_write(UVERBS_OBJECT_MR, cmd.mr_handle, attrs); if (IS_ERR(uobj)) |