Skip to content

Commit 35fdb30

Browse files
t-8chbjorn-helgaas
authored andcommitted
PCI/P2PDMA: Constify 'struct bin_attribute'
The sysfs core now allows instances of 'struct bin_attribute' to be moved into read-only memory. Make use of that to protect them against accidental or malicious modifications. Link: https://lore.kernel.org/r/20241202-sysfs-const-bin_attr-pci-v1-3-c32360f495a7@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
1 parent 3c39919 commit 35fdb30

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/pci/p2pdma.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int p2pmem_alloc_mmap(struct file *filp, struct kobject *kobj,
161161
return ret;
162162
}
163163

164-
static struct bin_attribute p2pmem_alloc_attr = {
164+
static const struct bin_attribute p2pmem_alloc_attr = {
165165
.attr = { .name = "allocate", .mode = 0660 },
166166
.mmap = p2pmem_alloc_mmap,
167167
/*
@@ -180,14 +180,14 @@ static struct attribute *p2pmem_attrs[] = {
180180
NULL,
181181
};
182182

183-
static struct bin_attribute *p2pmem_bin_attrs[] = {
183+
static const struct bin_attribute *const p2pmem_bin_attrs[] = {
184184
&p2pmem_alloc_attr,
185185
NULL,
186186
};
187187

188188
static const struct attribute_group p2pmem_group = {
189189
.attrs = p2pmem_attrs,
190-
.bin_attrs = p2pmem_bin_attrs,
190+
.bin_attrs_new = p2pmem_bin_attrs,
191191
.name = "p2pmem",
192192
};
193193

0 commit comments

Comments
 (0)