aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorChuhong Yuan <hslester96@gmail.com>2019-10-18 16:15:34 +0800
committerJason Gunthorpe <jgg@mellanox.com>2019-10-22 16:10:03 -0300
commita29e1012c1bf52c5364cad5ffbf5b4be8fe9c91b (patch)
treeabb5edfad7cc76c4cecb512f2485221762f06977 /drivers/infiniband
parentIB/cma: Honor traffic class from lower netdevice for RoCE (diff)
downloadlinux-dev-a29e1012c1bf52c5364cad5ffbf5b4be8fe9c91b.tar.xz
linux-dev-a29e1012c1bf52c5364cad5ffbf5b4be8fe9c91b.zip
RDMA/uverbs: Add a check for uverbs_attr_get to uverbs_copy_to_struct_or_zero
All current callers for uverbs_copy_to_struct_or_zero() already check that the attribute exists, but it make sense to verify the result like the other functions do. Link: https://lore.kernel.org/r/20191018081533.8544-1-hslester96@gmail.com Signed-off-by: Chuhong Yuan <hslester96@gmail.com> Reviewed-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/uverbs_ioctl.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/infiniband/core/uverbs_ioctl.c b/drivers/infiniband/core/uverbs_ioctl.c
index 61758201d9b2..269938f59d3f 100644
--- a/drivers/infiniband/core/uverbs_ioctl.c
+++ b/drivers/infiniband/core/uverbs_ioctl.c
@@ -795,6 +795,9 @@ int uverbs_copy_to_struct_or_zero(const struct uverbs_attr_bundle *bundle,
{
const struct uverbs_attr *attr = uverbs_attr_get(bundle, idx);
+ if (IS_ERR(attr))
+ return PTR_ERR(attr);
+
if (size < attr->ptr_attr.len) {
if (clear_user(u64_to_user_ptr(attr->ptr_attr.data) + size,
attr->ptr_attr.len - size))