@@ -865,8 +865,6 @@ static void uncore_types_exit(struct intel_uncore_type **types)
865
865
static int __init uncore_type_init (struct intel_uncore_type * type , bool setid )
866
866
{
867
867
struct intel_uncore_pmu * pmus ;
868
- struct attribute_group * attr_group ;
869
- struct attribute * * attrs ;
870
868
size_t size ;
871
869
int i , j ;
872
870
@@ -891,21 +889,24 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
891
889
0 , type -> num_counters , 0 , 0 );
892
890
893
891
if (type -> event_descs ) {
892
+ struct {
893
+ struct attribute_group group ;
894
+ struct attribute * attrs [];
895
+ } * attr_group ;
894
896
for (i = 0 ; type -> event_descs [i ].attr .attr .name ; i ++ );
895
897
896
- attr_group = kzalloc (sizeof ( struct attribute * ) * ( i + 1 ) +
897
- sizeof ( * attr_group ), GFP_KERNEL );
898
+ attr_group = kzalloc (struct_size ( attr_group , attrs , i + 1 ),
899
+ GFP_KERNEL );
898
900
if (!attr_group )
899
901
goto err ;
900
902
901
- attrs = (struct attribute * * )(attr_group + 1 );
902
- attr_group -> name = "events" ;
903
- attr_group -> attrs = attrs ;
903
+ attr_group -> group .name = "events" ;
904
+ attr_group -> group .attrs = attr_group -> attrs ;
904
905
905
906
for (j = 0 ; j < i ; j ++ )
906
- attrs [j ] = & type -> event_descs [j ].attr .attr ;
907
+ attr_group -> attrs [j ] = & type -> event_descs [j ].attr .attr ;
907
908
908
- type -> events_group = attr_group ;
909
+ type -> events_group = & attr_group -> group ;
909
910
}
910
911
911
912
type -> pmu_group = & uncore_pmu_attr_group ;
0 commit comments