Skip to content

Commit d802867

Browse files
t-8chJiri Kosina
authored andcommitted
HID: core: 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 725bf3d commit d802867

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/hid/hid-core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,7 +2175,7 @@ static bool hid_hiddev(struct hid_device *hdev)
21752175

21762176
static ssize_t
21772177
report_descriptor_read(struct file *filp, struct kobject *kobj,
2178-
struct bin_attribute *attr,
2178+
const struct bin_attribute *attr,
21792179
char *buf, loff_t off, size_t count)
21802180
{
21812181
struct device *dev = kobj_to_dev(kobj);
@@ -2201,7 +2201,7 @@ country_show(struct device *dev, struct device_attribute *attr,
22012201
return sprintf(buf, "%02x\n", hdev->country & 0xff);
22022202
}
22032203

2204-
static BIN_ATTR_RO(report_descriptor, HID_MAX_DESCRIPTOR_SIZE);
2204+
static const BIN_ATTR_RO(report_descriptor, HID_MAX_DESCRIPTOR_SIZE);
22052205

22062206
static const DEVICE_ATTR_RO(country);
22072207

@@ -2793,13 +2793,13 @@ static struct attribute *hid_dev_attrs[] = {
27932793
&dev_attr_modalias.attr,
27942794
NULL,
27952795
};
2796-
static struct bin_attribute *hid_dev_bin_attrs[] = {
2796+
static const struct bin_attribute *hid_dev_bin_attrs[] = {
27972797
&bin_attr_report_descriptor,
27982798
NULL
27992799
};
28002800
static const struct attribute_group hid_dev_group = {
28012801
.attrs = hid_dev_attrs,
2802-
.bin_attrs = hid_dev_bin_attrs,
2802+
.bin_attrs_new = hid_dev_bin_attrs,
28032803
};
28042804
__ATTRIBUTE_GROUPS(hid_dev);
28052805

0 commit comments

Comments
 (0)