@@ -173,7 +173,7 @@ tsm_mr_create_attribute_group(const struct tsm_measurements *tm)
173
173
* so that we don't have to free MR names one-by-one in
174
174
* tsm_mr_free_attribute_group()
175
175
*/
176
- const struct bin_attribute * const * attrs __free (kfree ) =
176
+ const struct bin_attribute * * attrs __free (kfree ) =
177
177
kzalloc (sizeof (* attrs ) * (tm -> nr_mrs + 1 ) + nlen , GFP_KERNEL );
178
178
struct tm_context * ctx __free (kfree ) =
179
179
kzalloc (struct_size (ctx , mrs , tm -> nr_mrs ), GFP_KERNEL );
@@ -187,16 +187,14 @@ tsm_mr_create_attribute_group(const struct tsm_measurements *tm)
187
187
end = name + nlen ;
188
188
189
189
for (size_t i = 0 ; i < tm -> nr_mrs ; ++ i ) {
190
- /* break const for init */
191
- struct bin_attribute * * bas = (struct bin_attribute * * )attrs ;
190
+ struct bin_attribute * bap = & ctx -> mrs [i ];
192
191
193
- bas [i ] = & ctx -> mrs [i ];
194
- sysfs_bin_attr_init (bas [i ]);
192
+ sysfs_bin_attr_init (bap );
195
193
196
194
if (tm -> mrs [i ].mr_flags & TSM_MR_F_NOHASH )
197
- bas [ i ] -> attr .name = tm -> mrs [i ].mr_name ;
195
+ bap -> attr .name = tm -> mrs [i ].mr_name ;
198
196
else if (name < end ) {
199
- bas [ i ] -> attr .name = name ;
197
+ bap -> attr .name = name ;
200
198
name += snprintf (name , end - name , "%s:%s" ,
201
199
tm -> mrs [i ].mr_name ,
202
200
hash_algo_name [tm -> mrs [i ].mr_hash ]);
@@ -206,21 +204,23 @@ tsm_mr_create_attribute_group(const struct tsm_measurements *tm)
206
204
207
205
/* check for duplicated MR definitions */
208
206
for (size_t j = 0 ; j < i ; ++ j )
209
- if (!strcmp (bas [ i ] -> attr .name , bas [j ]-> attr .name ))
207
+ if (!strcmp (bap -> attr .name , attrs [j ]-> attr .name ))
210
208
return ERR_PTR (- EINVAL );
211
209
212
210
if (tm -> mrs [i ].mr_flags & TSM_MR_F_READABLE ) {
213
- bas [ i ] -> attr .mode |= 0444 ;
214
- bas [ i ] -> read_new = tm_digest_read ;
211
+ bap -> attr .mode |= 0444 ;
212
+ bap -> read_new = tm_digest_read ;
215
213
}
216
214
217
215
if (tm -> mrs [i ].mr_flags & TSM_MR_F_WRITABLE ) {
218
- bas [ i ] -> attr .mode |= 0200 ;
219
- bas [ i ] -> write_new = tm_digest_write ;
216
+ bap -> attr .mode |= 0200 ;
217
+ bap -> write_new = tm_digest_write ;
220
218
}
221
219
222
- bas [i ]-> size = tm -> mrs [i ].mr_size ;
223
- bas [i ]-> private = ctx ;
220
+ bap -> size = tm -> mrs [i ].mr_size ;
221
+ bap -> private = ctx ;
222
+
223
+ attrs [i ] = bap ;
224
224
}
225
225
226
226
if (name != end )
@@ -244,7 +244,7 @@ EXPORT_SYMBOL_GPL(tsm_mr_create_attribute_group);
244
244
void tsm_mr_free_attribute_group (const struct attribute_group * attr_grp )
245
245
{
246
246
if (!IS_ERR_OR_NULL (attr_grp )) {
247
- kfree (attr_grp -> bin_attrs );
247
+ kfree (attr_grp -> bin_attrs_new );
248
248
kfree (container_of (attr_grp , struct tm_context , agrp ));
249
249
}
250
250
}
0 commit comments