diff options
author | Håkon Bugge <haakon.bugge@oracle.com> | 2021-11-23 11:06:18 +0100 |
---|---|---|
committer | Jason Gunthorpe <jgg@nvidia.com> | 2021-11-25 18:32:12 +0100 |
commit | 8d0d2b0f41b1b2add8a30dbd816051a964efa497 (patch) | |
tree | 9643dda050e6b362d68c549cceeb30fa53702b21 /drivers/infiniband | |
parent | RDMA/cxgb4: Use non-atomic bitmap functions when possible (diff) | |
download | linux-8d0d2b0f41b1b2add8a30dbd816051a964efa497.tar.xz linux-8d0d2b0f41b1b2add8a30dbd816051a964efa497.zip |
RDMA/cma: Remove open coding of overflow checking for private_data_len
The existing tests are a little hard to comprehend. Use
check_add_overflow() instead.
Fixes: 04ded1672402 ("RDMA/cma: Verify private data length")
Link: https://lore.kernel.org/r/1637661978-18770-1-git-send-email-haakon.bugge@oracle.com
Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
Reviewed-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/cma.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 835ac54d4a24..8a98aa90956f 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -4033,8 +4033,7 @@ static int cma_resolve_ib_udp(struct rdma_id_private *id_priv, memset(&req, 0, sizeof req); offset = cma_user_data_offset(id_priv); - req.private_data_len = offset + conn_param->private_data_len; - if (req.private_data_len < conn_param->private_data_len) + if (check_add_overflow(offset, conn_param->private_data_len, &req.private_data_len)) return -EINVAL; if (req.private_data_len) { @@ -4093,8 +4092,7 @@ static int cma_connect_ib(struct rdma_id_private *id_priv, memset(&req, 0, sizeof req); offset = cma_user_data_offset(id_priv); - req.private_data_len = offset + conn_param->private_data_len; - if (req.private_data_len < conn_param->private_data_len) + if (check_add_overflow(offset, conn_param->private_data_len, &req.private_data_len)) return -EINVAL; if (req.private_data_len) { |