Skip to content

Commit

Permalink
RDMA/ucma: Use struct_size() helper
Browse files Browse the repository at this point in the history
Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Gustavo A. R. Silva authored and Jason Gunthorpe committed Jun 7, 2019
1 parent 4f18904 commit 9bcb894
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/infiniband/core/ucma.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,7 @@ static ssize_t ucma_query_path(struct ucma_context *ctx,
}
}

if (copy_to_user(response, resp,
sizeof(*resp) + (i * sizeof(struct ib_path_rec_data))))
if (copy_to_user(response, resp, struct_size(resp, path_data, i)))
ret = -EFAULT;

kfree(resp);
Expand Down

0 comments on commit 9bcb894

Please sign in to comment.