bpf: Use struct_size() helper
[linux-2.6-microblaze.git] / kernel / bpf / reuseport_array.c
index 93a5539..556a769 100644 (file)
@@ -152,16 +152,12 @@ static struct bpf_map *reuseport_array_alloc(union bpf_attr *attr)
 {
        int numa_node = bpf_map_attr_numa_node(attr);
        struct reuseport_array *array;
-       u64 array_size;
 
        if (!bpf_capable())
                return ERR_PTR(-EPERM);
 
-       array_size = sizeof(*array);
-       array_size += (u64)attr->max_entries * sizeof(struct sock *);
-
        /* allocate all map elements and zero-initialize them */
-       array = bpf_map_area_alloc(array_size, numa_node);
+       array = bpf_map_area_alloc(struct_size(array, ptrs, attr->max_entries), numa_node);
        if (!array)
                return ERR_PTR(-ENOMEM);