Skip to content

Commit 7fd9d28

Browse files
t-8chWolfram Sang
authored andcommitted
i2c: slave-eeprom: 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: Wolfram Sang <[email protected]>
1 parent 3cfe39b commit 7fd9d28

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/i2c/i2c-slave-eeprom.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
9191
}
9292

9393
static ssize_t i2c_slave_eeprom_bin_read(struct file *filp, struct kobject *kobj,
94-
struct bin_attribute *attr, char *buf, loff_t off, size_t count)
94+
const struct bin_attribute *attr, char *buf, loff_t off, size_t count)
9595
{
9696
struct eeprom_data *eeprom;
9797
unsigned long flags;
@@ -106,7 +106,7 @@ static ssize_t i2c_slave_eeprom_bin_read(struct file *filp, struct kobject *kobj
106106
}
107107

108108
static ssize_t i2c_slave_eeprom_bin_write(struct file *filp, struct kobject *kobj,
109-
struct bin_attribute *attr, char *buf, loff_t off, size_t count)
109+
const struct bin_attribute *attr, char *buf, loff_t off, size_t count)
110110
{
111111
struct eeprom_data *eeprom;
112112
unsigned long flags;
@@ -165,8 +165,8 @@ static int i2c_slave_eeprom_probe(struct i2c_client *client)
165165
sysfs_bin_attr_init(&eeprom->bin);
166166
eeprom->bin.attr.name = "slave-eeprom";
167167
eeprom->bin.attr.mode = S_IRUSR | S_IWUSR;
168-
eeprom->bin.read = i2c_slave_eeprom_bin_read;
169-
eeprom->bin.write = i2c_slave_eeprom_bin_write;
168+
eeprom->bin.read_new = i2c_slave_eeprom_bin_read;
169+
eeprom->bin.write_new = i2c_slave_eeprom_bin_write;
170170
eeprom->bin.size = size;
171171

172172
ret = sysfs_create_bin_file(&client->dev.kobj, &eeprom->bin);

0 commit comments

Comments
 (0)