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@xxxxxxxxxxxxxx> --- drivers/scsi/lpfc/lpfc_attr.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 39b504164ecc187d8b0798c95c9fa3f6bc9780e3..0d0213bba35da8e10be8b874763dd5f01d6ff586 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -6185,7 +6185,7 @@ const struct attribute_group *lpfc_vport_groups[] = { **/ static ssize_t sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { size_t buf_off; @@ -6244,7 +6244,7 @@ sysfs_ctlreg_write(struct file *filp, struct kobject *kobj, **/ static ssize_t sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { size_t buf_off; @@ -6280,14 +6280,14 @@ sysfs_ctlreg_read(struct file *filp, struct kobject *kobj, return count; } -static struct bin_attribute sysfs_ctlreg_attr = { +static const struct bin_attribute sysfs_ctlreg_attr = { .attr = { .name = "ctlreg", .mode = S_IRUSR | S_IWUSR, }, .size = 256, - .read = sysfs_ctlreg_read, - .write = sysfs_ctlreg_write, + .read_new = sysfs_ctlreg_read, + .write_new = sysfs_ctlreg_write, }; /** @@ -6308,7 +6308,7 @@ static struct bin_attribute sysfs_ctlreg_attr = { **/ static ssize_t sysfs_mbox_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { return -EPERM; @@ -6332,20 +6332,20 @@ sysfs_mbox_write(struct file *filp, struct kobject *kobj, **/ static ssize_t sysfs_mbox_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, + const struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { return -EPERM; } -static struct bin_attribute sysfs_mbox_attr = { +static const struct bin_attribute sysfs_mbox_attr = { .attr = { .name = "mbox", .mode = S_IRUSR | S_IWUSR, }, .size = MAILBOX_SYSFS_MAX, - .read = sysfs_mbox_read, - .write = sysfs_mbox_write, + .read_new = sysfs_mbox_read, + .write_new = sysfs_mbox_write, }; /** -- 2.47.1