Skip to content

Commit ea4f221

Browse files
t-8chmartinkpetersen
authored andcommitted
scsi: qla4xxx: 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-11-f0a5e54b3437@weissschuh.net Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 06a9ceb commit ea4f221

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/scsi/qla4xxx/ql4_attr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
static ssize_t
1212
qla4_8xxx_sysfs_read_fw_dump(struct file *filep, struct kobject *kobj,
13-
struct bin_attribute *ba, char *buf, loff_t off,
13+
const struct bin_attribute *ba, char *buf, loff_t off,
1414
size_t count)
1515
{
1616
struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
@@ -28,7 +28,7 @@ qla4_8xxx_sysfs_read_fw_dump(struct file *filep, struct kobject *kobj,
2828

2929
static ssize_t
3030
qla4_8xxx_sysfs_write_fw_dump(struct file *filep, struct kobject *kobj,
31-
struct bin_attribute *ba, char *buf, loff_t off,
31+
const struct bin_attribute *ba, char *buf, loff_t off,
3232
size_t count)
3333
{
3434
struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
@@ -104,19 +104,19 @@ qla4_8xxx_sysfs_write_fw_dump(struct file *filep, struct kobject *kobj,
104104
return count;
105105
}
106106

107-
static struct bin_attribute sysfs_fw_dump_attr = {
107+
static const struct bin_attribute sysfs_fw_dump_attr = {
108108
.attr = {
109109
.name = "fw_dump",
110110
.mode = S_IRUSR | S_IWUSR,
111111
},
112112
.size = 0,
113-
.read = qla4_8xxx_sysfs_read_fw_dump,
114-
.write = qla4_8xxx_sysfs_write_fw_dump,
113+
.read_new = qla4_8xxx_sysfs_read_fw_dump,
114+
.write_new = qla4_8xxx_sysfs_write_fw_dump,
115115
};
116116

117117
static struct sysfs_entry {
118118
char *name;
119-
struct bin_attribute *attr;
119+
const struct bin_attribute *attr;
120120
} bin_file_entries[] = {
121121
{ "fw_dump", &sysfs_fw_dump_attr },
122122
{ NULL },

0 commit comments

Comments
 (0)