Skip to content

Commit 1cf448b

Browse files
t-8chmartinkpetersen
authored andcommitted
scsi: 3w-sas: 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/20241216-sysfs-const-bin_attr-scsi-v1-2-f0a5e54b3437@weissschuh.net Signed-off-by: Martin K. Petersen <[email protected]>
1 parent e4dab5d commit 1cf448b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/scsi/3w-sas.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static int twl_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_res
9696

9797
/* This function returns AENs through sysfs */
9898
static ssize_t twl_sysfs_aen_read(struct file *filp, struct kobject *kobj,
99-
struct bin_attribute *bin_attr,
99+
const struct bin_attribute *bin_attr,
100100
char *outbuf, loff_t offset, size_t count)
101101
{
102102
struct device *dev = container_of(kobj, struct device, kobj);
@@ -116,18 +116,18 @@ static ssize_t twl_sysfs_aen_read(struct file *filp, struct kobject *kobj,
116116
} /* End twl_sysfs_aen_read() */
117117

118118
/* aen_read sysfs attribute initializer */
119-
static struct bin_attribute twl_sysfs_aen_read_attr = {
119+
static const struct bin_attribute twl_sysfs_aen_read_attr = {
120120
.attr = {
121121
.name = "3ware_aen_read",
122122
.mode = S_IRUSR,
123123
},
124124
.size = 0,
125-
.read = twl_sysfs_aen_read
125+
.read_new = twl_sysfs_aen_read
126126
};
127127

128128
/* This function returns driver compatibility info through sysfs */
129129
static ssize_t twl_sysfs_compat_info(struct file *filp, struct kobject *kobj,
130-
struct bin_attribute *bin_attr,
130+
const struct bin_attribute *bin_attr,
131131
char *outbuf, loff_t offset, size_t count)
132132
{
133133
struct device *dev = container_of(kobj, struct device, kobj);
@@ -147,13 +147,13 @@ static ssize_t twl_sysfs_compat_info(struct file *filp, struct kobject *kobj,
147147
} /* End twl_sysfs_compat_info() */
148148

149149
/* compat_info sysfs attribute initializer */
150-
static struct bin_attribute twl_sysfs_compat_info_attr = {
150+
static const struct bin_attribute twl_sysfs_compat_info_attr = {
151151
.attr = {
152152
.name = "3ware_compat_info",
153153
.mode = S_IRUSR,
154154
},
155155
.size = 0,
156-
.read = twl_sysfs_compat_info
156+
.read_new = twl_sysfs_compat_info
157157
};
158158

159159
/* Show some statistics about the card */

0 commit comments

Comments
 (0)