Skip to content

Commit 738fa3f

Browse files
t-8chgeertu
authored andcommitted
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 <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/20241216-sysfs-const-bin_attr-zorro-v1-1-220a38d49507@weissschuh.net Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent f603143 commit 738fa3f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: drivers/zorro/zorro-sysfs.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static struct attribute *zorro_device_attrs[] = {
8181
};
8282

8383
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,
8585
char *buf, loff_t off, size_t count)
8686
{
8787
struct zorro_dev *z = to_zorro_dev(kobj_to_dev(kobj));
@@ -98,23 +98,23 @@ static ssize_t zorro_read_config(struct file *filp, struct kobject *kobj,
9898
return memory_read_from_buffer(buf, count, &off, &cd, sizeof(cd));
9999
}
100100

101-
static struct bin_attribute zorro_config_attr = {
101+
static const struct bin_attribute zorro_config_attr = {
102102
.attr = {
103103
.name = "config",
104104
.mode = S_IRUGO,
105105
},
106106
.size = sizeof(struct ConfigDev),
107-
.read = zorro_read_config,
107+
.read_new = zorro_read_config,
108108
};
109109

110-
static struct bin_attribute *zorro_device_bin_attrs[] = {
110+
static const struct bin_attribute *const zorro_device_bin_attrs[] = {
111111
&zorro_config_attr,
112112
NULL
113113
};
114114

115115
static const struct attribute_group zorro_device_attr_group = {
116116
.attrs = zorro_device_attrs,
117-
.bin_attrs = zorro_device_bin_attrs,
117+
.bin_attrs_new = zorro_device_bin_attrs,
118118
};
119119

120120
const struct attribute_group *zorro_device_attribute_groups[] = {

0 commit comments

Comments
 (0)