Skip to content

Commit 68489ba

Browse files
t-8chJiri Kosina
authored andcommitted
HID: roccat: arvo: 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]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 66f58ab commit 68489ba

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/hid/hid-roccat-arvo.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,24 +224,24 @@ static ssize_t arvo_sysfs_read(struct file *fp,
224224
}
225225

226226
static ssize_t arvo_sysfs_write_button(struct file *fp,
227-
struct kobject *kobj, struct bin_attribute *attr, char *buf,
228-
loff_t off, size_t count)
227+
struct kobject *kobj, const struct bin_attribute *attr,
228+
char *buf, loff_t off, size_t count)
229229
{
230230
return arvo_sysfs_write(fp, kobj, buf, off, count,
231231
sizeof(struct arvo_button), ARVO_COMMAND_BUTTON);
232232
}
233-
static BIN_ATTR(button, 0220, NULL, arvo_sysfs_write_button,
234-
sizeof(struct arvo_button));
233+
static const BIN_ATTR(button, 0220, NULL, arvo_sysfs_write_button,
234+
sizeof(struct arvo_button));
235235

236236
static ssize_t arvo_sysfs_read_info(struct file *fp,
237-
struct kobject *kobj, struct bin_attribute *attr, char *buf,
238-
loff_t off, size_t count)
237+
struct kobject *kobj, const struct bin_attribute *attr,
238+
char *buf, loff_t off, size_t count)
239239
{
240240
return arvo_sysfs_read(fp, kobj, buf, off, count,
241241
sizeof(struct arvo_info), ARVO_COMMAND_INFO);
242242
}
243-
static BIN_ATTR(info, 0440, arvo_sysfs_read_info, NULL,
244-
sizeof(struct arvo_info));
243+
static const BIN_ATTR(info, 0440, arvo_sysfs_read_info, NULL,
244+
sizeof(struct arvo_info));
245245

246246
static struct attribute *arvo_attrs[] = {
247247
&dev_attr_mode_key.attr,
@@ -250,15 +250,15 @@ static struct attribute *arvo_attrs[] = {
250250
NULL,
251251
};
252252

253-
static struct bin_attribute *arvo_bin_attributes[] = {
253+
static const struct bin_attribute *const arvo_bin_attributes[] = {
254254
&bin_attr_button,
255255
&bin_attr_info,
256256
NULL,
257257
};
258258

259259
static const struct attribute_group arvo_group = {
260260
.attrs = arvo_attrs,
261-
.bin_attrs = arvo_bin_attributes,
261+
.bin_attrs_new = arvo_bin_attributes,
262262
};
263263

264264
static const struct attribute_group *arvo_groups[] = {

0 commit comments

Comments
 (0)