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

Configure Feed

Select the types of activity you want to include in your feed.

of: 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/20241222-sysfs-const-bin_attr-of-v1-1-99cc2e8c2a55@weissschuh.net
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>

authored by

Thomas Weißschuh and committed by
Rob Herring (Arm)
a6a035a8 4c2a458e

+2 -2
+2 -2
drivers/of/kobj.c
··· 29 29 }; 30 30 31 31 static ssize_t of_node_property_read(struct file *filp, struct kobject *kobj, 32 - struct bin_attribute *bin_attr, char *buf, 32 + const struct bin_attribute *bin_attr, char *buf, 33 33 loff_t offset, size_t count) 34 34 { 35 35 struct property *pp = container_of(bin_attr, struct property, attr); ··· 77 77 pp->attr.attr.name = safe_name(&np->kobj, pp->name); 78 78 pp->attr.attr.mode = secure ? 0400 : 0444; 79 79 pp->attr.size = secure ? 0 : pp->length; 80 - pp->attr.read = of_node_property_read; 80 + pp->attr.read_new = of_node_property_read; 81 81 82 82 rc = sysfs_create_bin_file(&np->kobj, &pp->attr); 83 83 WARN(rc, "error adding attribute %s to node %pOF\n", pp->name, np);