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

hwmon: (occ/p9_sbe) 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/20241215-sysfs-const-bin_attr-hwmon-v1-1-ea72a6a46c36@weissschuh.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Thomas Weißschuh and committed by
Guenter Roeck
0f049da5 cf85760f

+2 -2
+2 -2
drivers/hwmon/occ/p9_sbe.c
··· 30 30 #define to_p9_sbe_occ(x) container_of((x), struct p9_sbe_occ, occ) 31 31 32 32 static ssize_t ffdc_read(struct file *filp, struct kobject *kobj, 33 - struct bin_attribute *battr, char *buf, loff_t pos, 33 + const struct bin_attribute *battr, char *buf, loff_t pos, 34 34 size_t count) 35 35 { 36 36 ssize_t rc = 0; ··· 48 48 49 49 return rc; 50 50 } 51 - static BIN_ATTR_RO(ffdc, OCC_MAX_RESP_WORDS * 4); 51 + static const BIN_ATTR_RO(ffdc, OCC_MAX_RESP_WORDS * 4); 52 52 53 53 static bool p9_sbe_occ_save_ffdc(struct p9_sbe_occ *ctx, const void *resp, 54 54 size_t resp_len)