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

zorro: 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>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://lore.kernel.org/20241216-sysfs-const-bin_attr-zorro-v1-1-220a38d49507@weissschuh.net
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

authored by

Thomas Weißschuh and committed by
Geert Uytterhoeven
738fa3fe f6031436

+5 -5
+5 -5
drivers/zorro/zorro-sysfs.c
··· 81 81 }; 82 82 83 83 static ssize_t zorro_read_config(struct file *filp, struct kobject *kobj, 84 - struct bin_attribute *bin_attr, 84 + const struct bin_attribute *bin_attr, 85 85 char *buf, loff_t off, size_t count) 86 86 { 87 87 struct zorro_dev *z = to_zorro_dev(kobj_to_dev(kobj)); ··· 98 98 return memory_read_from_buffer(buf, count, &off, &cd, sizeof(cd)); 99 99 } 100 100 101 - static struct bin_attribute zorro_config_attr = { 101 + static const struct bin_attribute zorro_config_attr = { 102 102 .attr = { 103 103 .name = "config", 104 104 .mode = S_IRUGO, 105 105 }, 106 106 .size = sizeof(struct ConfigDev), 107 - .read = zorro_read_config, 107 + .read_new = zorro_read_config, 108 108 }; 109 109 110 - static struct bin_attribute *zorro_device_bin_attrs[] = { 110 + static const struct bin_attribute *const zorro_device_bin_attrs[] = { 111 111 &zorro_config_attr, 112 112 NULL 113 113 }; 114 114 115 115 static const struct attribute_group zorro_device_attr_group = { 116 116 .attrs = zorro_device_attrs, 117 - .bin_attrs = zorro_device_bin_attrs, 117 + .bin_attrs_new = zorro_device_bin_attrs, 118 118 }; 119 119 120 120 const struct attribute_group *zorro_device_attribute_groups[] = {