Skip to content

Commit c4fb285

Browse files
committed
w1: Constify 'struct bin_attribute'
JIRA: https://issues.redhat.com/browse/RHEL-116876 commit 699e5f2 Author: Thomas Weißschuh <linux@weissschuh.net> Date: Wed Dec 11 18:50:16 2024 +0100 w1: 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/20241211-sysfs-const-bin_attr-w1-v1-1-c4befd2aa7cc@weissschuh.net Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
1 parent 99bc914 commit c4fb285

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/w1/w1.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ ATTRIBUTE_GROUPS(w1_slave);
111111
/* Default family */
112112

113113
static ssize_t rw_write(struct file *filp, struct kobject *kobj,
114-
struct bin_attribute *bin_attr, char *buf, loff_t off,
114+
const struct bin_attribute *bin_attr, char *buf, loff_t off,
115115
size_t count)
116116
{
117117
struct w1_slave *sl = kobj_to_w1_slave(kobj);
@@ -130,8 +130,8 @@ static ssize_t rw_write(struct file *filp, struct kobject *kobj,
130130
}
131131

132132
static ssize_t rw_read(struct file *filp, struct kobject *kobj,
133-
struct bin_attribute *bin_attr, char *buf, loff_t off,
134-
size_t count)
133+
const struct bin_attribute *bin_attr, char *buf,
134+
loff_t off, size_t count)
135135
{
136136
struct w1_slave *sl = kobj_to_w1_slave(kobj);
137137

@@ -141,15 +141,15 @@ static ssize_t rw_read(struct file *filp, struct kobject *kobj,
141141
return count;
142142
}
143143

144-
static BIN_ATTR_RW(rw, PAGE_SIZE);
144+
static const BIN_ATTR_RW(rw, PAGE_SIZE);
145145

146-
static struct bin_attribute *w1_slave_bin_attrs[] = {
146+
static const struct bin_attribute *const w1_slave_bin_attrs[] = {
147147
&bin_attr_rw,
148148
NULL,
149149
};
150150

151151
static const struct attribute_group w1_slave_default_group = {
152-
.bin_attrs = w1_slave_bin_attrs,
152+
.bin_attrs_new = w1_slave_bin_attrs,
153153
};
154154

155155
static const struct attribute_group *w1_slave_default_groups[] = {

0 commit comments

Comments
 (0)