Skip to content

Commit 9d948b8

Browse files
committed
Merge branch 'for-6.16/tsm-mr' into tsm-next
Pick up a couple fixes for issues noticed in linux-next (constification of bin_attrs and missing 'static').
2 parents 15ff5d0 + b0ca403 commit 9d948b8

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

drivers/virt/coco/guest/tsm-mr.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ tsm_mr_create_attribute_group(const struct tsm_measurements *tm)
173173
* so that we don't have to free MR names one-by-one in
174174
* tsm_mr_free_attribute_group()
175175
*/
176-
const struct bin_attribute * const *attrs __free(kfree) =
176+
const struct bin_attribute **attrs __free(kfree) =
177177
kzalloc(sizeof(*attrs) * (tm->nr_mrs + 1) + nlen, GFP_KERNEL);
178178
struct tm_context *ctx __free(kfree) =
179179
kzalloc(struct_size(ctx, mrs, tm->nr_mrs), GFP_KERNEL);
@@ -187,16 +187,14 @@ tsm_mr_create_attribute_group(const struct tsm_measurements *tm)
187187
end = name + nlen;
188188

189189
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];
192191

193-
bas[i] = &ctx->mrs[i];
194-
sysfs_bin_attr_init(bas[i]);
192+
sysfs_bin_attr_init(bap);
195193

196194
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;
198196
else if (name < end) {
199-
bas[i]->attr.name = name;
197+
bap->attr.name = name;
200198
name += snprintf(name, end - name, "%s:%s",
201199
tm->mrs[i].mr_name,
202200
hash_algo_name[tm->mrs[i].mr_hash]);
@@ -206,21 +204,23 @@ tsm_mr_create_attribute_group(const struct tsm_measurements *tm)
206204

207205
/* check for duplicated MR definitions */
208206
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))
210208
return ERR_PTR(-EINVAL);
211209

212210
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;
215213
}
216214

217215
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;
220218
}
221219

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;
224224
}
225225

226226
if (name != end)
@@ -244,7 +244,7 @@ EXPORT_SYMBOL_GPL(tsm_mr_create_attribute_group);
244244
void tsm_mr_free_attribute_group(const struct attribute_group *attr_grp)
245245
{
246246
if (!IS_ERR_OR_NULL(attr_grp)) {
247-
kfree(attr_grp->bin_attrs);
247+
kfree(attr_grp->bin_attrs_new);
248248
kfree(container_of(attr_grp, struct tm_context, agrp));
249249
}
250250
}

samples/tsm-mr/tsm_mr_sample.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <linux/miscdevice.h>
99
#include <crypto/hash.h>
1010

11-
struct {
11+
static struct {
1212
u8 static_mr[SHA384_DIGEST_SIZE];
1313
u8 config_mr[SHA512_DIGEST_SIZE];
1414
u8 rtmr0[SHA256_DIGEST_SIZE];

0 commit comments

Comments
 (0)