Skip to content

Commit 81ad38a

Browse files
t-8chAlexander Gordeev
authored andcommitted
s390/sclp: 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]> Acked-by: Alexander Gordeev <[email protected]> Link: https://lore.kernel.org/r/20241211-sysfs-const-bin_attr-s390-v1-4-be01f66bfcf7@weissschuh.net Signed-off-by: Alexander Gordeev <[email protected]>
1 parent ef37c66 commit 81ad38a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/s390/char/sclp_config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static int sclp_ofb_send_req(char *ev_data, size_t len)
128128
}
129129

130130
static ssize_t sysfs_ofb_data_write(struct file *filp, struct kobject *kobj,
131-
struct bin_attribute *bin_attr,
131+
const struct bin_attribute *bin_attr,
132132
char *buf, loff_t off, size_t count)
133133
{
134134
int rc;
@@ -142,7 +142,7 @@ static const struct bin_attribute ofb_bin_attr = {
142142
.name = "event_data",
143143
.mode = S_IWUSR,
144144
},
145-
.write = sysfs_ofb_data_write,
145+
.write_new = sysfs_ofb_data_write,
146146
};
147147
#endif
148148

drivers/s390/char/sclp_sd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ static struct kobj_type sclp_sd_file_ktype = {
476476
* on EOF.
477477
*/
478478
static ssize_t data_read(struct file *file, struct kobject *kobj,
479-
struct bin_attribute *attr, char *buffer,
479+
const struct bin_attribute *attr, char *buffer,
480480
loff_t off, size_t size)
481481
{
482482
struct sclp_sd_file *sd_file = to_sd_file(kobj);
@@ -539,7 +539,7 @@ static __init struct sclp_sd_file *sclp_sd_file_create(const char *name, u8 di)
539539
sysfs_bin_attr_init(&sd_file->data_attr);
540540
sd_file->data_attr.attr.name = "data";
541541
sd_file->data_attr.attr.mode = 0444;
542-
sd_file->data_attr.read = data_read;
542+
sd_file->data_attr.read_new = data_read;
543543

544544
rc = sysfs_create_bin_file(&sd_file->kobj, &sd_file->data_attr);
545545
if (rc) {

0 commit comments

Comments
 (0)