Skip to content

Commit 06aac7c

Browse files
committed
s390/pci: Constify 'struct bin_attribute'
JIRA: https://issues.redhat.com/browse/RHEL-116876 commit ef37c66 Author: Thomas Weißschuh <linux@weissschuh.net> Date: Wed Dec 11 18:54:41 2024 +0100 s390/pci: 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 <linux@weissschuh.net> Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Link: https://lore.kernel.org/r/20241211-sysfs-const-bin_attr-s390-v1-3-be01f66bfcf7@weissschuh.net Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Anusha Srivatsa <asrivats@redhat.com>
1 parent c31a51f commit 06aac7c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/s390/pci/pci_sysfs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static ssize_t recover_store(struct device *dev, struct device_attribute *attr,
126126
static DEVICE_ATTR_WO(recover);
127127

128128
static ssize_t util_string_read(struct file *filp, struct kobject *kobj,
129-
struct bin_attribute *attr, char *buf,
129+
const struct bin_attribute *attr, char *buf,
130130
loff_t off, size_t count)
131131
{
132132
struct device *dev = kobj_to_dev(kobj);
@@ -136,10 +136,10 @@ static ssize_t util_string_read(struct file *filp, struct kobject *kobj,
136136
return memory_read_from_buffer(buf, count, &off, zdev->util_str,
137137
sizeof(zdev->util_str));
138138
}
139-
static BIN_ATTR_RO(util_string, CLP_UTIL_STR_LEN);
139+
static const BIN_ATTR_RO(util_string, CLP_UTIL_STR_LEN);
140140

141141
static ssize_t report_error_write(struct file *filp, struct kobject *kobj,
142-
struct bin_attribute *attr, char *buf,
142+
const struct bin_attribute *attr, char *buf,
143143
loff_t off, size_t count)
144144
{
145145
struct zpci_report_error_header *report = (void *) buf;
@@ -155,7 +155,7 @@ static ssize_t report_error_write(struct file *filp, struct kobject *kobj,
155155

156156
return ret ? ret : count;
157157
}
158-
static BIN_ATTR(report_error, S_IWUSR, NULL, report_error_write, PAGE_SIZE);
158+
static const BIN_ATTR(report_error, S_IWUSR, NULL, report_error_write, PAGE_SIZE);
159159

160160
static ssize_t uid_is_unique_show(struct device *dev,
161161
struct device_attribute *attr, char *buf)
@@ -194,7 +194,7 @@ const struct attribute_group zpci_ident_attr_group = {
194194
.is_visible = zpci_index_is_visible,
195195
};
196196

197-
static struct bin_attribute *zpci_bin_attrs[] = {
197+
static const struct bin_attribute *const zpci_bin_attrs[] = {
198198
&bin_attr_util_string,
199199
&bin_attr_report_error,
200200
NULL,
@@ -218,7 +218,7 @@ static struct attribute *zpci_dev_attrs[] = {
218218

219219
const struct attribute_group zpci_attr_group = {
220220
.attrs = zpci_dev_attrs,
221-
.bin_attrs = zpci_bin_attrs,
221+
.bin_attrs_new = zpci_bin_attrs,
222222
};
223223

224224
static struct attribute *pfip_attrs[] = {

0 commit comments

Comments
 (0)