aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2018-06-07 10:57:16 -0400
committerKees Cook <keescook@chromium.org>2018-06-12 19:19:22 -0400
commit7654cb1ba7d0f312a6841d35d0f576db4723e8a3 (patch)
tree70bce312ae6b47e962a8623e64dd2c525a013116
parent5b572e25c3649235969e4ada67cde27b5bb24979 (diff)
Convert infiniband uverbs to struct_size
The flows were hidden from the C compiler; expose them as a zero-length array to allow struct_size to work. Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Signed-off-by: Kees Cook <keescook@chromium.org>
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c4
-rw-r--r--include/rdma/ib_verbs.h5
2 files changed, 3 insertions, 6 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 3179a95c6f5e..3e90b6a1d9d2 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -3559,8 +3559,8 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
3559 goto err_uobj; 3559 goto err_uobj;
3560 } 3560 }
3561 3561
3562 flow_attr = kzalloc(sizeof(*flow_attr) + cmd.flow_attr.num_of_specs * 3562 flow_attr = kzalloc(struct_size(flow_attr, flows,
3563 sizeof(union ib_flow_spec), GFP_KERNEL); 3563 cmd.flow_attr.num_of_specs), GFP_KERNEL);
3564 if (!flow_attr) { 3564 if (!flow_attr) {
3565 err = -ENOMEM; 3565 err = -ENOMEM;
3566 goto err_put; 3566 goto err_put;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 2043e1a8f851..4c6241bc2039 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2093,10 +2093,7 @@ struct ib_flow_attr {
2093 u32 flags; 2093 u32 flags;
2094 u8 num_of_specs; 2094 u8 num_of_specs;
2095 u8 port; 2095 u8 port;
2096 /* Following are the optional layers according to user request 2096 union ib_flow_spec flows[];
2097 * struct ib_flow_spec_xxx
2098 * struct ib_flow_spec_yyy
2099 */
2100}; 2097};
2101 2098
2102struct ib_flow { 2099struct ib_flow {