Commit 6566f907 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Kees Cook

Convert intel uncore to struct_size

Need to do a bit of rearranging to make this work.
Signed-off-by: default avatarMatthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
parent a3ac9730
...@@ -865,8 +865,6 @@ static void uncore_types_exit(struct intel_uncore_type **types) ...@@ -865,8 +865,6 @@ static void uncore_types_exit(struct intel_uncore_type **types)
static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
{ {
struct intel_uncore_pmu *pmus; struct intel_uncore_pmu *pmus;
struct attribute_group *attr_group;
struct attribute **attrs;
size_t size; size_t size;
int i, j; int i, j;
...@@ -891,21 +889,24 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) ...@@ -891,21 +889,24 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
0, type->num_counters, 0, 0); 0, type->num_counters, 0, 0);
if (type->event_descs) { if (type->event_descs) {
struct {
struct attribute_group group;
struct attribute *attrs[];
} *attr_group;
for (i = 0; type->event_descs[i].attr.attr.name; i++); for (i = 0; type->event_descs[i].attr.attr.name; i++);
attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) + attr_group = kzalloc(struct_size(attr_group, attrs, i + 1),
sizeof(*attr_group), GFP_KERNEL); GFP_KERNEL);
if (!attr_group) if (!attr_group)
goto err; goto err;
attrs = (struct attribute **)(attr_group + 1); attr_group->group.name = "events";
attr_group->name = "events"; attr_group->group.attrs = attr_group->attrs;
attr_group->attrs = attrs;
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
attrs[j] = &type->event_descs[j].attr.attr; attr_group->attrs[j] = &type->event_descs[j].attr.attr;
type->events_group = attr_group; type->events_group = &attr_group->group;
} }
type->pmu_group = &uncore_pmu_attr_group; type->pmu_group = &uncore_pmu_attr_group;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment