Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ocxl: 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>
Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
Link: https://lore.kernel.org/r/20241221-sysfs-const-bin_attr-misc-drivers-v2-1-ba5e79fe8771@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Greg Kroah-Hartman
0e3cd21c 95bc2d4a

+2 -2
+2 -2
drivers/misc/ocxl/sysfs.c
··· 94 94 }; 95 95 96 96 static ssize_t global_mmio_read(struct file *filp, struct kobject *kobj, 97 - struct bin_attribute *bin_attr, char *buf, 97 + const struct bin_attribute *bin_attr, char *buf, 98 98 loff_t off, size_t count) 99 99 { 100 100 struct ocxl_afu *afu = to_afu(kobj_to_dev(kobj)); ··· 155 155 info->attr_global_mmio.attr.name = "global_mmio_area"; 156 156 info->attr_global_mmio.attr.mode = 0600; 157 157 info->attr_global_mmio.size = info->afu->config.global_mmio_size; 158 - info->attr_global_mmio.read = global_mmio_read; 158 + info->attr_global_mmio.read_new = global_mmio_read; 159 159 info->attr_global_mmio.mmap = global_mmio_mmap; 160 160 rc = device_create_bin_file(&info->dev, &info->attr_global_mmio); 161 161 if (rc) {