Skip to content

Commit d5bdde0

Browse files
t-8chbjorn-helgaas
authored andcommitted
PCI/ACPI: 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-4-c32360f495a7@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 35fdb30 commit d5bdde0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/pci/hotplug/acpiphp_ibm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status);
8484
static void ibm_handle_events(acpi_handle handle, u32 event, void *context);
8585
static int ibm_get_table_from_acpi(char **bufp);
8686
static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj,
87-
struct bin_attribute *bin_attr,
87+
const struct bin_attribute *bin_attr,
8888
char *buffer, loff_t pos, size_t size);
8989
static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
9090
u32 lvl, void *context, void **rv);
@@ -98,7 +98,7 @@ static struct bin_attribute ibm_apci_table_attr __ro_after_init = {
9898
.name = "apci_table",
9999
.mode = S_IRUGO,
100100
},
101-
.read = ibm_read_apci_table,
101+
.read_new = ibm_read_apci_table,
102102
.write = NULL,
103103
};
104104
static struct acpiphp_attention_info ibm_attention_info =
@@ -353,7 +353,7 @@ static int ibm_get_table_from_acpi(char **bufp)
353353
* our solution is to only allow reading the table in all at once.
354354
*/
355355
static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj,
356-
struct bin_attribute *bin_attr,
356+
const struct bin_attribute *bin_attr,
357357
char *buffer, loff_t pos, size_t size)
358358
{
359359
int bytes_read = -EINVAL;

0 commit comments

Comments
 (0)