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

misc: eeprom/idt_89hpesx: 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/20241221-sysfs-const-bin_attr-misc-drivers-v2-7-ba5e79fe8771@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Greg Kroah-Hartman
6a43faaa e588522d

+3 -3
+3 -3
drivers/misc/eeprom/idt_89hpesx.c
··· 847 847 * @count: Number of bytes to write 848 848 */ 849 849 static ssize_t eeprom_write(struct file *filp, struct kobject *kobj, 850 - struct bin_attribute *attr, 850 + const struct bin_attribute *attr, 851 851 char *buf, loff_t off, size_t count) 852 852 { 853 853 struct idt_89hpesx_dev *pdev; ··· 871 871 * @count: Number of bytes to write 872 872 */ 873 873 static ssize_t eeprom_read(struct file *filp, struct kobject *kobj, 874 - struct bin_attribute *attr, 874 + const struct bin_attribute *attr, 875 875 char *buf, loff_t off, size_t count) 876 876 { 877 877 struct idt_89hpesx_dev *pdev; ··· 1017 1017 * NOTE Size will be changed in compliance with OF node. EEPROM attribute will 1018 1018 * be read-only as well if the corresponding flag is specified in OF node. 1019 1019 */ 1020 - static BIN_ATTR_RW(eeprom, EEPROM_DEF_SIZE); 1020 + static const BIN_ATTR_RW(eeprom, EEPROM_DEF_SIZE); 1021 1021 1022 1022 /* 1023 1023 * csr_dbgfs_ops - CSR debugfs-node read/write operations