Skip to content

Commit 7349678

Browse files
t-8chrafaeljw
authored andcommitted
ACPI: sysfs: 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. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://patch.msgid.link/20241202-sysfs-const-bin_attr-acpi-v1-3-78f3b38d350d@weissschuh.net Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent d16d7e9 commit 7349678

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/acpi/sysfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ struct acpi_data_attr {
319319
};
320320

321321
static ssize_t acpi_table_show(struct file *filp, struct kobject *kobj,
322-
struct bin_attribute *bin_attr, char *buf,
322+
const struct bin_attribute *bin_attr, char *buf,
323323
loff_t offset, size_t count)
324324
{
325325
struct acpi_table_attr *table_attr =
@@ -372,7 +372,7 @@ static int acpi_table_attr_init(struct kobject *tables_obj,
372372
}
373373

374374
table_attr->attr.size = table_header->length;
375-
table_attr->attr.read = acpi_table_show;
375+
table_attr->attr.read_new = acpi_table_show;
376376
table_attr->attr.attr.name = table_attr->filename;
377377
table_attr->attr.attr.mode = 0400;
378378

@@ -412,7 +412,7 @@ acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context)
412412
}
413413

414414
static ssize_t acpi_data_show(struct file *filp, struct kobject *kobj,
415-
struct bin_attribute *bin_attr, char *buf,
415+
const struct bin_attribute *bin_attr, char *buf,
416416
loff_t offset, size_t count)
417417
{
418418
struct acpi_data_attr *data_attr;
@@ -495,7 +495,7 @@ static int acpi_table_data_init(struct acpi_table_header *th)
495495
if (!data_attr)
496496
return -ENOMEM;
497497
sysfs_attr_init(&data_attr->attr.attr);
498-
data_attr->attr.read = acpi_data_show;
498+
data_attr->attr.read_new = acpi_data_show;
499499
data_attr->attr.attr.mode = 0400;
500500
return acpi_data_objs[i].fn(th, data_attr);
501501
}

0 commit comments

Comments
 (0)