Skip to content

Commit 6fcbc55

Browse files
t-8chTzung-Bi Shih
authored andcommitted
platform/chrome: cros_ec_vbc: 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]> Link: https://lore.kernel.org/r/20241215-sysfs-const-bin_attr-chrome-v1-1-92249c4bc295@weissschuh.net Signed-off-by: Tzung-Bi Shih <[email protected]>
1 parent 033fcee commit 6fcbc55

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/platform/chrome/cros_ec_vbc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#define DRV_NAME "cros-ec-vbc"
1616

1717
static ssize_t vboot_context_read(struct file *filp, struct kobject *kobj,
18-
struct bin_attribute *att, char *buf,
18+
const struct bin_attribute *att, char *buf,
1919
loff_t pos, size_t count)
2020
{
2121
struct device *dev = kobj_to_dev(kobj);
@@ -59,7 +59,7 @@ static ssize_t vboot_context_read(struct file *filp, struct kobject *kobj,
5959
}
6060

6161
static ssize_t vboot_context_write(struct file *filp, struct kobject *kobj,
62-
struct bin_attribute *attr, char *buf,
62+
const struct bin_attribute *attr, char *buf,
6363
loff_t pos, size_t count)
6464
{
6565
struct device *dev = kobj_to_dev(kobj);
@@ -99,16 +99,16 @@ static ssize_t vboot_context_write(struct file *filp, struct kobject *kobj,
9999
return data_sz;
100100
}
101101

102-
static BIN_ATTR_RW(vboot_context, 16);
102+
static const BIN_ATTR_RW(vboot_context, 16);
103103

104-
static struct bin_attribute *cros_ec_vbc_bin_attrs[] = {
104+
static const struct bin_attribute *const cros_ec_vbc_bin_attrs[] = {
105105
&bin_attr_vboot_context,
106106
NULL
107107
};
108108

109109
static const struct attribute_group cros_ec_vbc_attr_group = {
110110
.name = "vbc",
111-
.bin_attrs = cros_ec_vbc_bin_attrs,
111+
.bin_attrs_new = cros_ec_vbc_bin_attrs,
112112
};
113113

114114
static int cros_ec_vbc_probe(struct platform_device *pd)

0 commit comments

Comments
 (0)