Skip to content

Commit cdc6829

Browse files
t-8chJiri Kosina
authored andcommitted
HID: roccat: lua: 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> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent 79ef5c3 commit cdc6829

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/hid/hid-roccat-lua.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static ssize_t lua_sysfs_write(struct file *fp, struct kobject *kobj,
6666

6767
#define LUA_SYSFS_W(thingy, THINGY) \
6868
static ssize_t lua_sysfs_write_ ## thingy(struct file *fp, \
69-
struct kobject *kobj, struct bin_attribute *attr, \
69+
struct kobject *kobj, const struct bin_attribute *attr, \
7070
char *buf, loff_t off, size_t count) \
7171
{ \
7272
return lua_sysfs_write(fp, kobj, buf, off, count, \
@@ -75,7 +75,7 @@ static ssize_t lua_sysfs_write_ ## thingy(struct file *fp, \
7575

7676
#define LUA_SYSFS_R(thingy, THINGY) \
7777
static ssize_t lua_sysfs_read_ ## thingy(struct file *fp, \
78-
struct kobject *kobj, struct bin_attribute *attr, \
78+
struct kobject *kobj, const struct bin_attribute *attr, \
7979
char *buf, loff_t off, size_t count) \
8080
{ \
8181
return lua_sysfs_read(fp, kobj, buf, off, count, \
@@ -85,11 +85,11 @@ static ssize_t lua_sysfs_read_ ## thingy(struct file *fp, \
8585
#define LUA_BIN_ATTRIBUTE_RW(thingy, THINGY) \
8686
LUA_SYSFS_W(thingy, THINGY) \
8787
LUA_SYSFS_R(thingy, THINGY) \
88-
static struct bin_attribute lua_ ## thingy ## _attr = { \
88+
static const struct bin_attribute lua_ ## thingy ## _attr = { \
8989
.attr = { .name = #thingy, .mode = 0660 }, \
9090
.size = LUA_SIZE_ ## THINGY, \
91-
.read = lua_sysfs_read_ ## thingy, \
92-
.write = lua_sysfs_write_ ## thingy \
91+
.read_new = lua_sysfs_read_ ## thingy, \
92+
.write_new = lua_sysfs_write_ ## thingy \
9393
};
9494

9595
LUA_BIN_ATTRIBUTE_RW(control, CONTROL)

0 commit comments

Comments
 (0)