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

rapidio: 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://lore.kernel.org/r/20241216-sysfs-const-bin_attr-rapidio-v1-1-0f47f4719683@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Greg Kroah-Hartman
5d0fbf54 80f756ca

+7 -7
+7 -7
drivers/rapidio/rio-sysfs.c
··· 114 114 115 115 static ssize_t 116 116 rio_read_config(struct file *filp, struct kobject *kobj, 117 - struct bin_attribute *bin_attr, 117 + const struct bin_attribute *bin_attr, 118 118 char *buf, loff_t off, size_t count) 119 119 { 120 120 struct rio_dev *dev = to_rio_dev(kobj_to_dev(kobj)); ··· 185 185 186 186 static ssize_t 187 187 rio_write_config(struct file *filp, struct kobject *kobj, 188 - struct bin_attribute *bin_attr, 188 + const struct bin_attribute *bin_attr, 189 189 char *buf, loff_t off, size_t count) 190 190 { 191 191 struct rio_dev *dev = to_rio_dev(kobj_to_dev(kobj)); ··· 241 241 return count; 242 242 } 243 243 244 - static struct bin_attribute rio_config_attr = { 244 + static const struct bin_attribute rio_config_attr = { 245 245 .attr = { 246 246 .name = "config", 247 247 .mode = S_IRUGO | S_IWUSR, 248 248 }, 249 249 .size = RIO_MAINT_SPACE_SZ, 250 - .read = rio_read_config, 251 - .write = rio_write_config, 250 + .read_new = rio_read_config, 251 + .write_new = rio_write_config, 252 252 }; 253 253 254 - static struct bin_attribute *rio_dev_bin_attrs[] = { 254 + static const struct bin_attribute *const rio_dev_bin_attrs[] = { 255 255 &rio_config_attr, 256 256 NULL, 257 257 }; ··· 278 278 static const struct attribute_group rio_dev_group = { 279 279 .attrs = rio_dev_attrs, 280 280 .is_visible = rio_dev_is_attr_visible, 281 - .bin_attrs = rio_dev_bin_attrs, 281 + .bin_attrs_new = rio_dev_bin_attrs, 282 282 }; 283 283 284 284 const struct attribute_group *rio_dev_groups[] = {