* [PATCH] i2c: slave-eeprom: Constify 'struct bin_attribute'
@ 2024-12-15 13:21 Thomas Weißschuh
2025-01-09 9:51 ` Wolfram Sang
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Weißschuh @ 2024-12-15 13:21 UTC (permalink / raw)
To: Wolfram Sang; +Cc: linux-i2c, linux-kernel, Thomas Weißschuh
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>
---
drivers/i2c/i2c-slave-eeprom.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c
index 5946c0d0aef991aaa280a2df1d74d8a2ef09120f..275d1d0e910fbec72c4795cb3aafa714c52fcd94 100644
--- a/drivers/i2c/i2c-slave-eeprom.c
+++ b/drivers/i2c/i2c-slave-eeprom.c
@@ -91,7 +91,7 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
}
static ssize_t i2c_slave_eeprom_bin_read(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr, char *buf, loff_t off, size_t count)
+ const struct bin_attribute *attr, char *buf, loff_t off, size_t count)
{
struct eeprom_data *eeprom;
unsigned long flags;
@@ -106,7 +106,7 @@ static ssize_t i2c_slave_eeprom_bin_read(struct file *filp, struct kobject *kobj
}
static ssize_t i2c_slave_eeprom_bin_write(struct file *filp, struct kobject *kobj,
- struct bin_attribute *attr, char *buf, loff_t off, size_t count)
+ const struct bin_attribute *attr, char *buf, loff_t off, size_t count)
{
struct eeprom_data *eeprom;
unsigned long flags;
@@ -165,8 +165,8 @@ static int i2c_slave_eeprom_probe(struct i2c_client *client)
sysfs_bin_attr_init(&eeprom->bin);
eeprom->bin.attr.name = "slave-eeprom";
eeprom->bin.attr.mode = S_IRUSR | S_IWUSR;
- eeprom->bin.read = i2c_slave_eeprom_bin_read;
- eeprom->bin.write = i2c_slave_eeprom_bin_write;
+ eeprom->bin.read_new = i2c_slave_eeprom_bin_read;
+ eeprom->bin.write_new = i2c_slave_eeprom_bin_write;
eeprom->bin.size = size;
ret = sysfs_create_bin_file(&client->dev.kobj, &eeprom->bin);
---
base-commit: 2d8308bf5b67dff50262d8a9260a50113b3628c6
change-id: 20241215-sysfs-const-bin_attr-i2c-5f1bbc48f590
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i2c: slave-eeprom: Constify 'struct bin_attribute'
2024-12-15 13:21 [PATCH] i2c: slave-eeprom: Constify 'struct bin_attribute' Thomas Weißschuh
@ 2025-01-09 9:51 ` Wolfram Sang
0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2025-01-09 9:51 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: linux-i2c, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 351 bytes --]
On Sun, Dec 15, 2024 at 02:21:39PM +0100, Thomas Weißschuh wrote:
> 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>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-09 9:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-15 13:21 [PATCH] i2c: slave-eeprom: Constify 'struct bin_attribute' Thomas Weißschuh
2025-01-09 9:51 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).