Skip to content

Commit 0344559

Browse files
t-8chJiri Kosina
authored andcommitted
HID: roccat: isku: 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 68489ba commit 0344559

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

drivers/hid/hid-roccat-isku.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static ssize_t isku_sysfs_write(struct file *fp, struct kobject *kobj,
156156

157157
#define ISKU_SYSFS_W(thingy, THINGY) \
158158
static ssize_t isku_sysfs_write_ ## thingy(struct file *fp, struct kobject *kobj, \
159-
struct bin_attribute *attr, char *buf, \
159+
const struct bin_attribute *attr, char *buf, \
160160
loff_t off, size_t count) \
161161
{ \
162162
return isku_sysfs_write(fp, kobj, buf, off, count, \
@@ -165,7 +165,7 @@ static ssize_t isku_sysfs_write_ ## thingy(struct file *fp, struct kobject *kobj
165165

166166
#define ISKU_SYSFS_R(thingy, THINGY) \
167167
static ssize_t isku_sysfs_read_ ## thingy(struct file *fp, struct kobject *kobj, \
168-
struct bin_attribute *attr, char *buf, \
168+
const struct bin_attribute *attr, char *buf, \
169169
loff_t off, size_t count) \
170170
{ \
171171
return isku_sysfs_read(fp, kobj, buf, off, count, \
@@ -178,27 +178,27 @@ ISKU_SYSFS_W(thingy, THINGY)
178178

179179
#define ISKU_BIN_ATTR_RW(thingy, THINGY) \
180180
ISKU_SYSFS_RW(thingy, THINGY); \
181-
static struct bin_attribute bin_attr_##thingy = { \
181+
static const struct bin_attribute bin_attr_##thingy = { \
182182
.attr = { .name = #thingy, .mode = 0660 }, \
183183
.size = ISKU_SIZE_ ## THINGY, \
184-
.read = isku_sysfs_read_ ## thingy, \
185-
.write = isku_sysfs_write_ ## thingy \
184+
.read_new = isku_sysfs_read_ ## thingy, \
185+
.write_new = isku_sysfs_write_ ## thingy \
186186
}
187187

188188
#define ISKU_BIN_ATTR_R(thingy, THINGY) \
189189
ISKU_SYSFS_R(thingy, THINGY); \
190-
static struct bin_attribute bin_attr_##thingy = { \
190+
static const struct bin_attribute bin_attr_##thingy = { \
191191
.attr = { .name = #thingy, .mode = 0440 }, \
192192
.size = ISKU_SIZE_ ## THINGY, \
193-
.read = isku_sysfs_read_ ## thingy, \
193+
.read_new = isku_sysfs_read_ ## thingy, \
194194
}
195195

196196
#define ISKU_BIN_ATTR_W(thingy, THINGY) \
197197
ISKU_SYSFS_W(thingy, THINGY); \
198-
static struct bin_attribute bin_attr_##thingy = { \
198+
static const struct bin_attribute bin_attr_##thingy = { \
199199
.attr = { .name = #thingy, .mode = 0220 }, \
200200
.size = ISKU_SIZE_ ## THINGY, \
201-
.write = isku_sysfs_write_ ## thingy \
201+
.write_new = isku_sysfs_write_ ## thingy \
202202
}
203203

204204
ISKU_BIN_ATTR_RW(macro, MACRO);
@@ -217,7 +217,7 @@ ISKU_BIN_ATTR_W(control, CONTROL);
217217
ISKU_BIN_ATTR_W(reset, RESET);
218218
ISKU_BIN_ATTR_R(info, INFO);
219219

220-
static struct bin_attribute *isku_bin_attributes[] = {
220+
static const struct bin_attribute *const isku_bin_attributes[] = {
221221
&bin_attr_macro,
222222
&bin_attr_keys_function,
223223
&bin_attr_keys_easyzone,
@@ -238,7 +238,7 @@ static struct bin_attribute *isku_bin_attributes[] = {
238238

239239
static const struct attribute_group isku_group = {
240240
.attrs = isku_attrs,
241-
.bin_attrs = isku_bin_attributes,
241+
.bin_attrs_new = isku_bin_attributes,
242242
};
243243

244244
static const struct attribute_group *isku_groups[] = {

0 commit comments

Comments
 (0)